diff --git a/contracts/helper/DummyERC20.sol b/contracts/helper/DummyERC20.sol new file mode 100644 index 00000000..e52f6767 --- /dev/null +++ b/contracts/helper/DummyERC20.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import "@openzeppelin/contracts-4.7.3/token/ERC20/presets/ERC20PresetMinterPauser.sol"; + +contract DummyERC20 is ERC20PresetMinterPauser { + constructor(string memory name, string memory symbol) + ERC20PresetMinterPauser(name, symbol) + {} + + function mint(address to, uint256 amount) public virtual override { + assert(amount <= 10000000000000000000); + _mint(to, amount); + } +} diff --git a/deploy/base_testnet/002_deploy_LPTokenV2.ts b/deploy/base_testnet/002_deploy_LPTokenV2.ts new file mode 100644 index 00000000..3860e307 --- /dev/null +++ b/deploy/base_testnet/002_deploy_LPTokenV2.ts @@ -0,0 +1,29 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { deploy, execute, getOrNull, log } = deployments + const { deployer } = await getNamedAccounts() + + const lpToken = await getOrNull("LPTokenV2") + if (lpToken) { + log(`reusing "LPTokenV2" at ${lpToken.address}`) + } else { + await deploy("LPTokenV2", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }) + + await execute( + "LPTokenV2", + { from: deployer, log: true }, + "initialize", + "Saddle LP Token (Target)", + "saddleLPTokenTarget", + ) + } +} +export default func +func.tags = ["LPTokenV2"] diff --git a/deploy/base_testnet/003_deploy_AmplificationUtilsV2.ts b/deploy/base_testnet/003_deploy_AmplificationUtilsV2.ts new file mode 100644 index 00000000..9a1f7501 --- /dev/null +++ b/deploy/base_testnet/003_deploy_AmplificationUtilsV2.ts @@ -0,0 +1,16 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, getChainId } = hre + const { deploy } = deployments + const { deployer } = await getNamedAccounts() + + await deploy("AmplificationUtilsV2", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }) +} +export default func +func.tags = ["AmplificationUtilsV2"] diff --git a/deploy/base_testnet/004_deploy_SwapUtilsV2.ts b/deploy/base_testnet/004_deploy_SwapUtilsV2.ts new file mode 100644 index 00000000..8ebd16f2 --- /dev/null +++ b/deploy/base_testnet/004_deploy_SwapUtilsV2.ts @@ -0,0 +1,16 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, getChainId } = hre + const { deploy, get } = deployments + const { deployer } = await getNamedAccounts() + + await deploy("SwapUtilsV2", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }) +} +export default func +func.tags = ["SwapUtilsV2"] diff --git a/deploy/base_testnet/005_deploy_MetaSwapUtilsV1.ts b/deploy/base_testnet/005_deploy_MetaSwapUtilsV1.ts new file mode 100644 index 00000000..81aae6fa --- /dev/null +++ b/deploy/base_testnet/005_deploy_MetaSwapUtilsV1.ts @@ -0,0 +1,16 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { deploy, get } = deployments + const { deployer } = await getNamedAccounts() + + await deploy("MetaSwapUtilsV1", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }) +} +export default func +func.tags = ["MetaSwapUtilsV1"] diff --git a/deploy/base_testnet/008_deploy_PoolRegistry.ts b/deploy/base_testnet/008_deploy_PoolRegistry.ts new file mode 100644 index 00000000..92b0c0b5 --- /dev/null +++ b/deploy/base_testnet/008_deploy_PoolRegistry.ts @@ -0,0 +1,17 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, getChainId, ethers } = hre + const { deploy, get, execute } = deployments + const { deployer } = await getNamedAccounts() + + await deploy("PoolRegistry", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: [deployer, deployer], + }) +} +export default func +func.tags = ["PoolRegistry"] diff --git a/deploy/base_testnet/009_deploy_MasterRegistry.ts b/deploy/base_testnet/009_deploy_MasterRegistry.ts new file mode 100644 index 00000000..5ead121d --- /dev/null +++ b/deploy/base_testnet/009_deploy_MasterRegistry.ts @@ -0,0 +1,51 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" +import { MasterRegistry } from "../../build/typechain" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, getChainId, ethers } = hre + const { deploy, get, getOrNull, execute, read } = deployments + const { deployer } = await getNamedAccounts() + + const masterRegistry = await getOrNull("MasterRegistry") + + if (masterRegistry == null) { + await deploy("MasterRegistry", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: [deployer], + }) + + const contract = (await ethers.getContract( + "MasterRegistry", + )) as MasterRegistry + + const batchCall = [ + await contract.populateTransaction.addRegistry( + ethers.utils.formatBytes32String("PoolRegistry"), + ( + await get("PoolRegistry") + ).address, + ), + await contract.populateTransaction.addRegistry( + ethers.utils.formatBytes32String("FeeCollector"), + deployer, + ), + ] + + const batchCallData = batchCall + .map((x) => x.data) + .filter((x): x is string => !!x) + + await execute( + "MasterRegistry", + { from: deployer, log: true }, + "batch", + batchCallData, + true, + ) + } +} +export default func +func.tags = ["MasterRegistry"] diff --git a/deploy/base_testnet/010_permissionless_deployments.ts b/deploy/base_testnet/010_permissionless_deployments.ts new file mode 100644 index 00000000..ee571ae8 --- /dev/null +++ b/deploy/base_testnet/010_permissionless_deployments.ts @@ -0,0 +1,20 @@ +import dotenv from "dotenv" +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" +import { deployPermissionlessPoolComponentsV2 } from "../deployUtils" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + dotenv.config() + + await deployPermissionlessPoolComponentsV2(hre) +} +export default func +func.tags = ["PermissionlessSwaps"] +func.dependencies = [ + "MasterRegistry", + "PoolRegistry", + "SwapUtilsV2", + "AmplificationUtilsV2", + "MetaSwapUtilsV1", + "LPTokenV2", +] diff --git a/deploy/base_testnet/011_deploy_mintableDummyTokens.ts b/deploy/base_testnet/011_deploy_mintableDummyTokens.ts new file mode 100644 index 00000000..05f7cd4e --- /dev/null +++ b/deploy/base_testnet/011_deploy_mintableDummyTokens.ts @@ -0,0 +1,36 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { deploy, save } = deployments + const { deployer } = await getNamedAccounts() + + const dummyToken1 = await deploy("Dummy1", { + contract: "DummyERC20", + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: ["FreeMintableDummyERC20_1", "Dummy1"], + }) + + // save token deployment + await save("Dummy1", { + abi: dummyToken1.abi, + address: dummyToken1.address, + }) + + const dummyToken2 = await deploy("Dummy2", { + contract: "DummyERC20", + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: ["FreeMintableDummyERC20_2", "Dummy2"], + }) + // save token deployment + await save("Dummy2", { + abi: dummyToken2.abi, + address: dummyToken2.address, + }) +} +export default func diff --git a/deploy/base_testnet/012_deploy_DummyTokenPool.ts b/deploy/base_testnet/012_deploy_DummyTokenPool.ts new file mode 100644 index 00000000..2492c568 --- /dev/null +++ b/deploy/base_testnet/012_deploy_DummyTokenPool.ts @@ -0,0 +1,76 @@ +import { HardhatRuntimeEnvironment } from "hardhat/types" +import { DeployFunction } from "hardhat-deploy/types" +import { ZERO_ADDRESS } from "../../test/testUtils" + +// Deployment Names +const POOL_NAME = "SaddleDummyPool" + +const TOKEN_NAMES = ["Dummy1", "Dummy2"] +const LP_TOKEN_NAME = "Saddle Dummy1/Dummy2 LP Token" +const LP_TOKEN_SYMBOL = "SaddleDummyBP" +const INITIAL_A = 500 +const SWAP_FEE = 4e6 // 4bps +const ADMIN_FEE = 0 // 50% of the 3bps + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, deploy, get, getOrNull, log, read, save } = deployments + const { deployer } = await getNamedAccounts() + const poolLpTokenName = `${POOL_NAME}LPToken` + + // Manually check if the pool is already deployed + const poolContract = await getOrNull(POOL_NAME) + + // Check if has been initialized + const isInitialized: boolean = poolContract + ? (await read(POOL_NAME, "swapStorage")).lpToken !== ZERO_ADDRESS + : false + + if (poolContract && isInitialized) { + log(`reusing ${POOL_NAME} at ${poolContract.address}`) + } else { + const TOKEN_ADDRESSES = await Promise.all( + TOKEN_NAMES.map(async (name) => (await get(name)).address), + ) + + await deploy(POOL_NAME, { + from: deployer, + log: true, + contract: "SwapV2", + skipIfAlreadyDeployed: true, + libraries: { + SwapUtilsV2: (await get("SwapUtilsV2")).address, + AmplificationUtilsV2: (await get("AmplificationUtilsV2")).address, + }, + }) + await execute( + POOL_NAME, + { + from: deployer, + log: true, + }, + "initialize", + TOKEN_ADDRESSES, + [18, 18], + LP_TOKEN_NAME, + LP_TOKEN_SYMBOL, + INITIAL_A, + SWAP_FEE, + ADMIN_FEE, + ( + await get("LPTokenV2") + ).address, + ) + + const lpTokenAddress = (await read(POOL_NAME, "swapStorage")).lpToken + log(`deployed ${poolLpTokenName} at ${lpTokenAddress}`) + + await save(poolLpTokenName, { + abi: (await get("LPTokenV2")).abi, // LPToken ABI + address: lpTokenAddress, + }) + } +} +export default func +func.tags = [POOL_NAME] +func.dependencies = ["SwapUtilsV2"] diff --git a/deploy/base_testnet/999_verify_all_contracts.ts b/deploy/base_testnet/999_verify_all_contracts.ts new file mode 100644 index 00000000..6ef0ca82 --- /dev/null +++ b/deploy/base_testnet/999_verify_all_contracts.ts @@ -0,0 +1,31 @@ +import { DeployFunction } from "hardhat-deploy/types" +import { HardhatRuntimeEnvironment } from "hardhat/types" +import { CHAIN_ID } from "../../utils/network" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getChainId, network } = hre + const { log } = deployments + const network_deployments = await deployments.all() + + // for (const deployment in network_deployments) { + if ( + (await getChainId()) === CHAIN_ID.BASE_TESTNET && + network.name !== "hardhat" + ) { + try { + await hre.run("etherscan-verify", { + network: "base_testnet", + apiKey: process.env.ETHERSCAN_API, + }) + } catch (e) { + log(e) + } + } else { + log( + `Skipping verification since this is not running on ${CHAIN_ID.BASE_TESTNET}`, + ) + } +} +// } +export default func +// func.skip = async (env) => true diff --git a/deploy/deployUtils.ts b/deploy/deployUtils.ts index f59fb6aa..9e702fd8 100644 --- a/deploy/deployUtils.ts +++ b/deploy/deployUtils.ts @@ -1130,6 +1130,174 @@ export async function deployPermissionlessPoolComponents( console.log("All permissionless contracts deployed :)") } +/** + * @notice Deploy all contracts on a certain chain for permissionless + * pool deployment functionalities, with updated contract versions. + * @param hre HardhatRuntimeEnvironment variable + */ +export async function deployPermissionlessPoolComponentsV2( + hre: HardhatRuntimeEnvironment, +) { + const { deployments, getNamedAccounts, getChainId, ethers } = hre + const { deploy, get, getOrNull, execute } = deployments + const { deployer } = await getNamedAccounts() + + const permissionlessSwap = await getOrNull("PermissionlessSwapV1") + const permissionlessMetaSwap = await getOrNull("PermissionlessMetaSwapV1") + const permissionlessDeployer = await getOrNull("PermissionlessDeployer") + const masterRegistry: MasterRegistry = await ethers.getContract( + "MasterRegistry", + deployer, + ) + const masterRegistryAddress = masterRegistry.address + const swapUtilsAddress = (await get("SwapUtilsV2")).address + const amplificationUtilsAddress = (await get("AmplificationUtilsV2")).address + const metaSwapUtilsAddress = (await get("MetaSwapUtilsV1")).address + const metaswapDeposit = await getOrNull("MetaPoolDepositV1") + let metaswapDepositAddress = metaswapDeposit?.address + // see if master registry has a fee collector set + const feeCollectorName = ethers.utils.formatBytes32String("FeeCollector") + + // skip following txs if permissionless deployer is deployed + if (permissionlessDeployer) { + return + } + + // get multisig address for network, if there is none default to deployer + let rolesAssignedTo = "multisig" + let multisig = MULTISIG_ADDRESSES[await getChainId()] + if (multisig === undefined) { + console.log("No multisig address found for network, defaulting to deployer") + multisig = deployer + rolesAssignedTo = "deployer" + } + + // Check if deployer has the default admin role + const deployerHasRole = await masterRegistry.hasRole( + await masterRegistry.DEFAULT_ADMIN_ROLE(), + deployer, + ) + try { + await masterRegistry.resolveNameToLatestAddress(feeCollectorName) + } catch (error) { + console.log(`No fee collector set, attempting to set to ${rolesAssignedTo}`) + + if (deployerHasRole) { + await execute( + "MasterRegistry", + { + from: deployer, + log: true, + }, + "addRegistry", + feeCollectorName, + multisig, + ) + } else { + console.log( + `Deployer does not have default admin role, ${rolesAssignedTo} was NOT set as fee collector`, + ) + } + } + + // Deploy an instance of MetaSwapDeposit if not found + if (metaswapDeposit == undefined) { + console.log("Deploying MetaSwapDeposit") + const metaSwapDepositDeployment = await deploy("MetaSwapDepositV1", { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + }) + metaswapDepositAddress = metaSwapDepositDeployment.address + } + + // deploy PermissionlessSwap if needed + if (permissionlessSwap == null) { + console.log("PermissionlessSwap not found, deploying") + await deploy("PermissionlessSwapV1", { + contract: "PermissionlessSwap", + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: [masterRegistryAddress], + libraries: { + SwapUtils: swapUtilsAddress, + AmplificationUtils: amplificationUtilsAddress, + }, + }) + } + const permissionlessSwapAddress = (await get("PermissionlessSwapV1")).address + + // deploy PermissionlessMetaSwap if needed + if (permissionlessMetaSwap == null) { + console.log("PermissionlessMetaSwap not found, deploying") + await deploy("PermissionlessMetaSwapV1", { + contract: "PermissionlessMetaSwap", + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: [masterRegistryAddress], + libraries: { + SwapUtils: swapUtilsAddress, + MetaSwapUtils: metaSwapUtilsAddress, + AmplificationUtils: amplificationUtilsAddress, + }, + }) + } + const permissionlessMetaSwapAddress = (await get("PermissionlessMetaSwapV1")) + .address + + // deploy PermissionlessDeployer + if (permissionlessDeployer == null) { + console.log("PermissionlessDeployer not found, deploying") + + const PermissionlessDeployerDeployment = await deploy( + "PermissionlessDeployer", + { + from: deployer, + log: true, + skipIfAlreadyDeployed: true, + args: [ + multisig, // admin + masterRegistryAddress, // masterRegistry + ( + await get("LPTokenV2") + ).address, // targetLPToken + permissionlessSwapAddress, // targetSwap + permissionlessMetaSwapAddress, // targetMetaSwap + // Below needs to be a non-clone instance of the MetaswapDeposit Contract + metaswapDepositAddress, // targetMetaSwapDeposit + ], + }, + ) + console.log( + "PermissionlessDeployer deployed at", + PermissionlessDeployerDeployment.address, + ) + + // PermissionlessDeployer to the master registry if the deployer can + + if (deployerHasRole) { + console.log("Adding PermissionlessDeployer to MasterRegistry") + await execute( + "MasterRegistry", + { + from: deployer, + log: true, + }, + "addRegistry", + ethers.utils.formatBytes32String("PermissionlessDeployer"), + PermissionlessDeployerDeployment.address, + ) + } else { + console.log( + "PermissionlessDeployer not added to MasterRegistry, multisig tx required", + ) + } + } + console.log("All permissionless contracts deployed :)") +} + /** * @notice Deploy child gauges for given record of lp token name to registry name * @param {HardhatRuntimeEnvironment} hre HardhatRuntimeEnvironment diff --git a/deployments/base_testnet/.chainId b/deployments/base_testnet/.chainId new file mode 100644 index 00000000..9b24bf02 --- /dev/null +++ b/deployments/base_testnet/.chainId @@ -0,0 +1 @@ +84531 \ No newline at end of file diff --git a/deployments/base_testnet/AmplificationUtilsV2.json b/deployments/base_testnet/AmplificationUtilsV2.json new file mode 100644 index 00000000..d53725ee --- /dev/null +++ b/deployments/base_testnet/AmplificationUtilsV2.json @@ -0,0 +1,163 @@ +{ + "address": "0xFdA5D2ad8b6d3884AbB799DA66f57175E8706941", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "initialTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "RampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "StopRampA", + "type": "event" + }, + { + "inputs": [], + "name": "A_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_A", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xca92d9d68440b191795ebeef7907686a2813905cfa29893d94863ceb271d8214", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xFdA5D2ad8b6d3884AbB799DA66f57175E8706941", + "transactionIndex": 2, + "gasUsed": "423951", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x0cf6ba5f5146f0dbc1cf456a3cb9ed4b874b82e53da4f9dda5673517cdb9ccd8", + "transactionHash": "0xca92d9d68440b191795ebeef7907686a2813905cfa29893d94863ceb271d8214", + "logs": [], + "blockNumber": 2668387, + "cumulativeGasUsed": "492250", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialTime\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"RampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"currentA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"}],\"name\":\"StopRampA\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"A_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_A\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getA(SwapUtilsV2.Swap storage)\":{\"details\":\"See the StableSwap paper for details\",\"params\":{\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"A parameter\"}},\"getAPrecise(SwapUtilsV2.Swap storage)\":{\"details\":\"See the StableSwap paper for details\",\"params\":{\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"A parameter in its raw precision form\"}},\"rampA(SwapUtilsV2.Swap storage,uint256,uint256)\":{\"params\":{\"futureA_\":\"the new A to ramp towards\",\"futureTime_\":\"timestamp when the new A should be reached\",\"self\":\"Swap struct to update\"}},\"stopRampA(SwapUtilsV2.Swap storage)\":{\"params\":{\"self\":\"Swap struct to update\"}}},\"title\":\"AmplificationUtils library\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getA(SwapUtilsV2.Swap storage)\":{\"notice\":\"Return A, the amplification coefficient * n * (n - 1)\"},\"getAPrecise(SwapUtilsV2.Swap storage)\":{\"notice\":\"Return A in its raw precision\"},\"rampA(SwapUtilsV2.Swap storage,uint256,uint256)\":{\"notice\":\"Start ramping up or down A parameter towards given futureA_ and futureTime_ Checks if the change is too rapid, and commits the new A value only when it falls under the limit range.\"},\"stopRampA(SwapUtilsV2.Swap storage)\":{\"notice\":\"Stops ramping A immediately. Once this function is called, rampA() cannot be called for another 24 hours\"}},\"notice\":\"A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct. This library assumes the struct is fully validated.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AmplificationUtilsV2.sol\":\"AmplificationUtilsV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/AmplificationUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./SwapUtilsV2.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtilsV2 {\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return (_getAPrecise(self) / A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtilsV2.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return a0 + (((a1 - a0) * (block.timestamp - t0)) / (t1 - t0));\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return a0 - (((a0 - a1) * (block.timestamp - t0)) / (t1 - t0));\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtilsV2.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= (self.initialATime + (1 days)),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= (block.timestamp + MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_ * A_PRECISION;\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n (futureAPrecise * MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= (initialAPrecise * MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtilsV2.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0xb52146d1964ede58f1cb59bff4fa507d30eeae9b11c213941bcbda047fe9e4fb\",\"license\":\"MIT\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/MathUtilsV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtilsV1 {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x39534ffe365ac4796eebdd5d505ed58c425bc65861ccf118eb0f6cd26c654f0b\",\"license\":\"MIT\"},\"contracts/SwapUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtilsV2.sol\\\";\\nimport \\\"./LPTokenV2.sol\\\";\\nimport \\\"./MathUtilsV1.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtilsV2 {\\n using SafeERC20 for IERC20;\\n using MathUtilsV1 for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPTokenV2 lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPTokenV2 lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount * (fee) / (FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtilsV2._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = ((currentY - newY) /\\n self.tokenPrecisionMultipliers[tokenIndex]) - dy;\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] =\\n xpi -\\n (((\\n (i == tokenIndex)\\n ? ((xpi * v.d1) / v.d0) - v.newY\\n : xpi - ((xpi * v.d1) / v.d0)\\n ) * v.feePerToken) / FEE_DENOMINATOR);\\n }\\n\\n uint256 dy = xpReduced[tokenIndex] -\\n (getYD(v.preciseA, tokenIndex, xpReduced, v.d1));\\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a * (numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s + xp[i];\\n c = (c * d) / (xp[i] * (numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = ((y * y) + c) / ((y * 2) + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s + xp[i];\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a * numTokens;\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = (dP * d) / (xp[j] * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d =\\n ((((nA * s) / AmplificationUtilsV2.A_PRECISION) +\\n (dP * numTokens)) * d) /\\n ((((nA - AmplificationUtilsV2.A_PRECISION) * d) /\\n AmplificationUtilsV2.A_PRECISION) + ((numTokens + 1) * dP));\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i] * precisionMultipliers[i];\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPTokenV2 lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return (d * (10**uint256(POOL_PRECISION_DECIMALS))) / supply;\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens * preciseA;\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s + _x;\\n c = (c * d) / (_x * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = (y * y + c) / (y * 2 + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx * multipliers[tokenIndexFrom] + xp[tokenIndexFrom];\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo] - y - 1;\\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\\n dy = (dy - dyFee) / multipliers[tokenIndexTo];\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = (balances[i] * amount) / totalSupply;\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i] + amounts[i];\\n } else {\\n if (amounts[i] > balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances[i] = balances[i] - amounts[i];\\n }\\n }\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return (((d1 - d0) * totalSupply) / d0);\\n } else {\\n return (((d0 - d1) * totalSupply) / d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)) -\\n self.balances[index];\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return ((swapFee * numTokens) / ((numTokens - 1) * 4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)) - beforeBalance;\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = (((dyFee * self.adminFee) / FEE_DENOMINATOR) /\\n self.tokenPrecisionMultipliers[tokenIndexTo]);\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom] + dx;\\n self.balances[tokenIndexTo] = balances[tokenIndexTo] - dy - dyAdminFee;\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] =\\n pooledTokens[i].balanceOf(address(this)) -\\n beforeBalance;\\n }\\n\\n newBalances[i] = v.balances[i] + amounts[i];\\n }\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n fees[i] =\\n (feePerToken * idealBalance.difference(newBalances[i])) /\\n FEE_DENOMINATOR;\\n self.balances[i] =\\n newBalances[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n newBalances[i] = newBalances[i] - fees[i];\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply + toMint\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i] - amounts[i];\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply - amount);\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] =\\n self.balances[tokenIndex] -\\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n if (amounts[i] > v.balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = v.balances[i] - amounts[i];\\n }\\n }\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\\n self.balances[i] =\\n balances1[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n balances1[i] = balances1[i] - fees[i];\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount + 1;\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply - tokenAmount\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)) - self.balances[i];\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0xb8d3f47b58b85bddeeb59cc13049f3f7fee2b29ee373fe5427d1f7c8814a1b8b\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6106c261003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061007c5760003560e01c8063c4a241f71161005a578063c4a241f7146100d2578063d011f918146100e5578063d3a605a5146100ed57600080fd5b80631c103df01461008157806339698415146100a6578063858490d3146100b0575b600080fd5b61009461008f3660046105a0565b61010d565b60405190815260200160405180910390f35b610094620f424081565b8180156100bc57600080fd5b506100d06100cb3660046105b9565b61012a565b005b6100946100e03660046105a0565b610410565b610094606481565b8180156100f957600080fd5b506100d06101083660046105a0565b61041b565b6000606461011a836104f2565b6101249190610614565b92915050565b600283015461013c906201518061064f565b4210156101aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f57616974203120646179206265666f7265207374617274696e672072616d700060448201526064015b60405180910390fd5b6101b7621275004261064f565b811015610220576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e73756666696369656e742072616d702074696d650000000000000000000060448201526064016101a1565b6000821180156102325750620f424082105b610298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f667574757265415f206d757374206265203e203020616e64203c204d41585f4160448201526064016101a1565b60006102a3846104f2565b905060006102b2606485610662565b90508181101561033557816102c8600283610662565b1015610330576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f667574757265415f20697320746f6f20736d616c6c000000000000000000000060448201526064016101a1565b6103a9565b610340600283610662565b8111156103a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f667574757265415f20697320746f6f206c61726765000000000000000000000060448201526064016101a1565b8185556001850181905542600286018190556003860184905560408051848152602081018490528082019290925260608201859052517fa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c2549181900360800190a15050505050565b6000610124826104f2565b42816003015411610488576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f52616d7020697320616c72656164792073746f7070656400000000000000000060448201526064016101a1565b6000610493826104f2565b808355600183018190554260028401819055600384018190556040519192507f46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc201938916104e691848252602082015260400190565b60405180910390a15050565b60038101546001820154600091904282111561059957600284015484548083111561055d576105218285610679565b61052b8342610679565b6105358386610679565b61053f9190610662565b6105499190610614565b610553908261064f565b9695505050505050565b6105678285610679565b6105718342610679565b61057b8584610679565b6105859190610662565b61058f9190610614565b6105539082610679565b9392505050565b6000602082840312156105b257600080fd5b5035919050565b6000806000606084860312156105ce57600080fd5b505081359360208301359350604090920135919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008261064a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b80820180821115610124576101246105e5565b8082028115828204841417610124576101246105e5565b81810381811115610124576101246105e556fea2646970667358221220f8cf13bb67b262cdd38cab7f22643f364d1b7bfa512270e7eb6042233035baf064736f6c63430008110033", + "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040526004361061007c5760003560e01c8063c4a241f71161005a578063c4a241f7146100d2578063d011f918146100e5578063d3a605a5146100ed57600080fd5b80631c103df01461008157806339698415146100a6578063858490d3146100b0575b600080fd5b61009461008f3660046105a0565b61010d565b60405190815260200160405180910390f35b610094620f424081565b8180156100bc57600080fd5b506100d06100cb3660046105b9565b61012a565b005b6100946100e03660046105a0565b610410565b610094606481565b8180156100f957600080fd5b506100d06101083660046105a0565b61041b565b6000606461011a836104f2565b6101249190610614565b92915050565b600283015461013c906201518061064f565b4210156101aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f57616974203120646179206265666f7265207374617274696e672072616d700060448201526064015b60405180910390fd5b6101b7621275004261064f565b811015610220576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e73756666696369656e742072616d702074696d650000000000000000000060448201526064016101a1565b6000821180156102325750620f424082105b610298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f667574757265415f206d757374206265203e203020616e64203c204d41585f4160448201526064016101a1565b60006102a3846104f2565b905060006102b2606485610662565b90508181101561033557816102c8600283610662565b1015610330576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f667574757265415f20697320746f6f20736d616c6c000000000000000000000060448201526064016101a1565b6103a9565b610340600283610662565b8111156103a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f667574757265415f20697320746f6f206c61726765000000000000000000000060448201526064016101a1565b8185556001850181905542600286018190556003860184905560408051848152602081018490528082019290925260608201859052517fa2b71ec6df949300b59aab36b55e189697b750119dd349fcfa8c0f779e83c2549181900360800190a15050505050565b6000610124826104f2565b42816003015411610488576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f52616d7020697320616c72656164792073746f7070656400000000000000000060448201526064016101a1565b6000610493826104f2565b808355600183018190554260028401819055600384018190556040519192507f46e22fb3709ad289f62ce63d469248536dbc78d82b84a3d7e74ad606dc201938916104e691848252602082015260400190565b60405180910390a15050565b60038101546001820154600091904282111561059957600284015484548083111561055d576105218285610679565b61052b8342610679565b6105358386610679565b61053f9190610662565b6105499190610614565b610553908261064f565b9695505050505050565b6105678285610679565b6105718342610679565b61057b8584610679565b6105859190610662565b61058f9190610614565b6105539082610679565b9392505050565b6000602082840312156105b257600080fd5b5035919050565b6000806000606084860312156105ce57600080fd5b505081359360208301359350604090920135919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008261064a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b80820180821115610124576101246105e5565b8082028115828204841417610124576101246105e5565b81810381811115610124576101246105e556fea2646970667358221220f8cf13bb67b262cdd38cab7f22643f364d1b7bfa512270e7eb6042233035baf064736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "getA(SwapUtilsV2.Swap storage)": { + "details": "See the StableSwap paper for details", + "params": { + "self": "Swap struct to read from" + }, + "returns": { + "_0": "A parameter" + } + }, + "getAPrecise(SwapUtilsV2.Swap storage)": { + "details": "See the StableSwap paper for details", + "params": { + "self": "Swap struct to read from" + }, + "returns": { + "_0": "A parameter in its raw precision form" + } + }, + "rampA(SwapUtilsV2.Swap storage,uint256,uint256)": { + "params": { + "futureA_": "the new A to ramp towards", + "futureTime_": "timestamp when the new A should be reached", + "self": "Swap struct to update" + } + }, + "stopRampA(SwapUtilsV2.Swap storage)": { + "params": { + "self": "Swap struct to update" + } + } + }, + "title": "AmplificationUtils library", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getA(SwapUtilsV2.Swap storage)": { + "notice": "Return A, the amplification coefficient * n * (n - 1)" + }, + "getAPrecise(SwapUtilsV2.Swap storage)": { + "notice": "Return A in its raw precision" + }, + "rampA(SwapUtilsV2.Swap storage,uint256,uint256)": { + "notice": "Start ramping up or down A parameter towards given futureA_ and futureTime_ Checks if the change is too rapid, and commits the new A value only when it falls under the limit range." + }, + "stopRampA(SwapUtilsV2.Swap storage)": { + "notice": "Stops ramping A immediately. Once this function is called, rampA() cannot be called for another 24 hours" + } + }, + "notice": "A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct. This library assumes the struct is fully validated.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/base_testnet/Dummy1.json b/deployments/base_testnet/Dummy1.json new file mode 100644 index 00000000..bd02474d --- /dev/null +++ b/deployments/base_testnet/Dummy1.json @@ -0,0 +1,667 @@ +{ + "address": "0xF6C2e0aDc659007Ba7c48446F5A4e4E94dfe08b5", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "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" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINTER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PAUSER_ROLE", + "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": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "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": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "to", + "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": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "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": [], + "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": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "numDeployments": 3 +} diff --git a/deployments/base_testnet/Dummy2.json b/deployments/base_testnet/Dummy2.json new file mode 100644 index 00000000..68862bb8 --- /dev/null +++ b/deployments/base_testnet/Dummy2.json @@ -0,0 +1,667 @@ +{ + "address": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "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" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINTER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PAUSER_ROLE", + "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": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "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": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "to", + "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": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "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": [], + "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": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "numDeployments": 3 +} diff --git a/deployments/base_testnet/DummyERC20.json b/deployments/base_testnet/DummyERC20.json new file mode 100644 index 00000000..c07df2ee --- /dev/null +++ b/deployments/base_testnet/DummyERC20.json @@ -0,0 +1,1024 @@ +{ + "address": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "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" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MINTER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PAUSER_ROLE", + "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": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "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": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "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": "to", + "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": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "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": [], + "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": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x0bd8ecee75418865520c6780731d264f53e5cde0c5a37666844619f856b37f35", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "transactionIndex": 1, + "gasUsed": "2081752", + "logsBloom": "0x00000004000400000000000000800000000000004000400000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000000001000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000001000000000000100002000000020000000000000004000000000000000000000000400000080000000000000000000", + "blockHash": "0x6890d467ae0d965a847498c6bbb10b52abfb5f91b8e4ea627ef427c52bc35012", + "transactionHash": "0x0bd8ecee75418865520c6780731d264f53e5cde0c5a37666844619f856b37f35", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 2717505, + "transactionHash": "0x0bd8ecee75418865520c6780731d264f53e5cde0c5a37666844619f856b37f35", + "address": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x6890d467ae0d965a847498c6bbb10b52abfb5f91b8e4ea627ef427c52bc35012" + }, + { + "transactionIndex": 1, + "blockNumber": 2717505, + "transactionHash": "0x0bd8ecee75418865520c6780731d264f53e5cde0c5a37666844619f856b37f35", + "address": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x6890d467ae0d965a847498c6bbb10b52abfb5f91b8e4ea627ef427c52bc35012" + }, + { + "transactionIndex": 1, + "blockNumber": 2717505, + "transactionHash": "0x0bd8ecee75418865520c6780731d264f53e5cde0c5a37666844619f856b37f35", + "address": "0x9893a51F1aa81586754527D2fd8b30F3c2e06e3a", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x6890d467ae0d965a847498c6bbb10b52abfb5f91b8e4ea627ef427c52bc35012" + } + ], + "blockNumber": 2717505, + "cumulativeGasUsed": "2081752", + "status": 1, + "byzantium": true + }, + "args": ["FreeMintableDummyERC20_2", "Dummy2"], + "numDeployments": 4, + "solcInputHash": "5d7138b5466db9111ae85d9f4162357d", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"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\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MINTER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PAUSER_ROLE\",\"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\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"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\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"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\":\"to\",\"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\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"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\":[],\"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\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"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(uint256)\":{\"details\":\"Destroys `amount` tokens from the caller. See {ERC20-_burn}.\"},\"burnFrom(address,uint256)\":{\"details\":\"Destroys `amount` tokens from `account`, deducting from the caller's allowance. See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``'s tokens of at least `amount`.\"},\"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`.\"},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"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` new tokens for `to`. See {ERC20-_mint}. Requirements: - the caller must have the `MINTER_ROLE`.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"pause()\":{\"details\":\"Pauses all token transfers. See {ERC20Pausable} and {Pausable-_pause}. Requirements: - the caller must have the `PAUSER_ROLE`.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"},\"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`.\"},\"unpause()\":{\"details\":\"Unpauses all token transfers. See {ERC20Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/helper/DummyERC20.sol\":\"DummyERC20\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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(uint160(account), 20),\\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\",\"keccak256\":\"0x5b35d8e68aeaccc685239bd9dd79b9ba01a0357930f8a3307ab85511733d9724\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0x13f5e15f2a0650c0b6aaee2ef19e89eaf4870d6e79662d572a393334c1397247\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0x59ce320a585d7e1f163cd70390a0ef2ff9cec832e2aa544293a00692465a7a57\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0xba4459ab871dfa300f5212c6c30178b63898c03533a1ede28436f11546626676\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0x0849d93b16c9940beb286a7864ed02724b248b93e0d80ef6355af5ef15c64773\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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\",\"keccak256\":\"0x0d19410453cda55960a818e02bd7c18952a5c8fe7a3036e81f0d599f34487a7b\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0x978847fbff92d66d27d8767402a90ba996970b1936b372406aa17f5492bd8dc5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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\",\"keccak256\":\"0x2cd54808b851c4db22f459065af0b7a952262741a85a73923e7a660767cd7baa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n 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 // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\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\":\"0xaf159a8b1923ad2a26d516089bceca9bdeaeacd04be50983ea00ba63070f08a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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\",\"keccak256\":\"0xd10975de010d89fd1c78dc5e8a9a7e7f496198085c151648f20cba166b32582b\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/structs/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\\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 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 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 return _values(set._inner);\\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 on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n\\n /**\\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\":\"0x5050943b32b6a8f282573d166b2e9d87ab7eb4dbba4ab6acf36ecb54fe6995e4\",\"license\":\"MIT\"},\"contracts/helper/DummyERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/presets/ERC20PresetMinterPauser.sol\\\";\\n\\ncontract DummyERC20 is ERC20PresetMinterPauser {\\n constructor(string memory name, string memory symbol)\\n ERC20PresetMinterPauser(name, symbol)\\n {}\\n\\n function mint(address to, uint256 amount) public virtual override {\\n assert(amount <= 10000000000000000000);\\n _mint(to, amount);\\n }\\n}\\n\",\"keccak256\":\"0xbe1183aa0b346f91eadafdcd4666888b12481bbbda95ed37816a04f38bc1f6ce\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162002379380380620023798339810160408190526200003491620002fb565b818181816005620000468382620003f3565b506006620000558282620003f3565b50506007805460ff19169055506200006f600033620000d1565b6200009b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633620000d1565b620000c77f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a33620000d1565b50505050620004bf565b620000dd8282620000e1565b5050565b620000f882826200012460201b6200099c1760201c565b60008281526001602090815260409091206200011f91839062000a8c620001c4821b17901c565b505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620000dd576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001803390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620001db836001600160a01b038416620001e4565b90505b92915050565b60008181526001830160205260408120546200022d57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620001de565b506000620001de565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200025e57600080fd5b81516001600160401b03808211156200027b576200027b62000236565b604051601f8301601f19908116603f01168101908282118183101715620002a657620002a662000236565b81604052838152602092508683858801011115620002c357600080fd5b600091505b83821015620002e75785820183015181830184015290820190620002c8565b600093810190920192909252949350505050565b600080604083850312156200030f57600080fd5b82516001600160401b03808211156200032757600080fd5b62000335868387016200024c565b935060208501519150808211156200034c57600080fd5b506200035b858286016200024c565b9150509250929050565b600181811c908216806200037a57607f821691505b6020821081036200039b57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200011f57600081815260208120601f850160051c81016020861015620003ca5750805b601f850160051c820191505b81811015620003eb57828155600101620003d6565b505050505050565b81516001600160401b038111156200040f576200040f62000236565b620004278162000420845462000365565b84620003a1565b602080601f8311600181146200045f5760008415620004465750858301515b600019600386901b1c1916600185901b178555620003eb565b600085815260208120601f198616915b8281101562000490578886015182559484019460019091019084016200046f565b5085821015620004af5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b611eaa80620004cf6000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c806370a08231116100f9578063a457c2d711610097578063d539139311610071578063d5391393146103fa578063d547741f14610421578063dd62ed3e14610434578063e63ab1e91461047a57600080fd5b8063a457c2d7146103c1578063a9059cbb146103d4578063ca15c873146103e757600080fd5b80639010d07c116100d35780639010d07c1461033557806391d148541461036d57806395d89b41146103b1578063a217fddf146103b957600080fd5b806370a08231146102e457806379cc67901461031a5780638456cb591461032d57600080fd5b8063313ce567116101665780633f4ba83a116101405780633f4ba83a146102ab57806340c10f19146102b357806342966c68146102c65780635c975abb146102d957600080fd5b8063313ce5671461027657806336568abe14610285578063395093511461029857600080fd5b806318160ddd116101a257806318160ddd1461021957806323b872dd1461022b578063248a9ca31461023e5780632f2ff15d1461026157600080fd5b806301ffc9a7146101c957806306fdde03146101f1578063095ea7b314610206575b600080fd5b6101dc6101d7366004611a51565b6104a1565b60405190151581526020015b60405180910390f35b6101f96104fd565b6040516101e89190611ab7565b6101dc610214366004611b31565b61058f565b6004545b6040519081526020016101e8565b6101dc610239366004611b5b565b6105a7565b61021d61024c366004611b97565b60009081526020819052604090206001015490565b61027461026f366004611bb0565b6105cb565b005b604051601281526020016101e8565b610274610293366004611bb0565b6105f5565b6101dc6102a6366004611b31565b610693565b6102746106df565b6102746102c1366004611b31565b610785565b6102746102d4366004611b97565b6107a7565b60075460ff166101dc565b61021d6102f2366004611bdc565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090205490565b610274610328366004611b31565b6107b4565b6102746107c9565b610348610343366004611bf7565b61086d565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e8565b6101dc61037b366004611bb0565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6101f961088c565b61021d600081565b6101dc6103cf366004611b31565b61089b565b6101dc6103e2366004611b31565b610952565b61021d6103f5366004611b97565b610960565b61021d7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b61027461042f366004611bb0565b610977565b61021d610442366004611c19565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260036020908152604080832093909416825291909152205490565b61021d7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f0000000000000000000000000000000000000000000000000000000014806104f757506104f782610aae565b92915050565b60606005805461050c90611c43565b80601f016020809104026020016040519081016040528092919081815260200182805461053890611c43565b80156105855780601f1061055a57610100808354040283529160200191610585565b820191906000526020600020905b81548152906001019060200180831161056857829003601f168201915b5050505050905090565b60003361059d818585610b45565b5060019392505050565b6000336105b5858285610cc4565b6105c0858585610d81565b506001949350505050565b6000828152602081905260409020600101546105e681610ff1565b6105f08383610ffb565b505050565b73ffffffffffffffffffffffffffffffffffffffff811633146106855760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b61068f828261101d565b5050565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061059d90829086906106da908790611cc5565b610b45565b6107097f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a3361037b565b61077b5760405162461bcd60e51b815260206004820152603960248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20756e706175736500000000000000606482015260840161067c565b61078361103f565b565b678ac7230489e8000081111561079d5761079d611cd8565b61068f82826110bc565b6107b133826111ce565b50565b6107bf823383610cc4565b61068f82826111ce565b6107f37f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a3361037b565b6108655760405162461bcd60e51b815260206004820152603760248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f207061757365000000000000000000606482015260840161067c565b610783611393565b600082815260016020526040812061088590836113ee565b9392505050565b60606006805461050c90611c43565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156109455760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161067c565b6105c08286868403610b45565b60003361059d818585610d81565b60008181526001602052604081206104f7906113fa565b60008281526020819052604090206001015461099281610ff1565b6105f0838361101d565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661068f5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610a2e3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006108858373ffffffffffffffffffffffffffffffffffffffff8416611404565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806104f757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146104f7565b73ffffffffffffffffffffffffffffffffffffffff8316610bcd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8216610c565760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600360209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610d7b5781811015610d6e5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161067c565b610d7b8484848403610b45565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610e0a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8216610e935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161067c565b610e9e838383611453565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090205481811015610f3a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260026020526040808220858503905591851681529081208054849290610f7e908490611cc5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610fe491815260200190565b60405180910390a3610d7b565b6107b1813361145e565b611005828261099c565b60008281526001602052604090206105f09082610a8c565b6110278282611514565b60008281526001602052604090206105f090826115cb565b6110476115ed565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b73ffffffffffffffffffffffffffffffffffffffff821661111f5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161067c565b61112b60008383611453565b806004600082825461113d9190611cc5565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604081208054839290611177908490611cc5565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112575760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b61126382600083611453565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054818110156112ff5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040812083830390556004805484929061133b908490611d07565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b61139b61163f565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110923390565b60006108858383611692565b60006104f7825490565b600081815260018301602052604081205461144b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104f7565b5060006104f7565b6105f08383836116bc565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661068f576114b48173ffffffffffffffffffffffffffffffffffffffff166014611735565b6114bf836020611735565b6040516020016114d0929190611d1a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262461bcd60e51b825261067c91600401611ab7565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff161561068f5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006108858373ffffffffffffffffffffffffffffffffffffffff841661195e565b60075460ff166107835760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161067c565b60075460ff16156107835760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161067c565b60008260000182815481106116a9576116a9611d9b565b9060005260206000200154905092915050565b60075460ff16156105f05760405162461bcd60e51b815260206004820152602a60248201527f45524332305061757361626c653a20746f6b656e207472616e7366657220776860448201527f696c652070617573656400000000000000000000000000000000000000000000606482015260840161067c565b60606000611744836002611dca565b61174f906002611cc5565b67ffffffffffffffff81111561176757611767611de1565b6040519080825280601f01601f191660200182016040528015611791576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106117c8576117c8611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061182b5761182b611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611867846002611dca565b611872906001611cc5565b90505b600181111561190f577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106118b3576118b3611d9b565b1a60f81b8282815181106118c9576118c9611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361190881611e10565b9050611875565b5083156108855760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161067c565b60008181526001830160205260408120548015611a47576000611982600183611d07565b855490915060009061199690600190611d07565b90508181146119fb5760008660000182815481106119b6576119b6611d9b565b90600052602060002001549050808760000184815481106119d9576119d9611d9b565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a0c57611a0c611e45565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104f7565b60009150506104f7565b600060208284031215611a6357600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461088557600080fd5b60005b83811015611aae578181015183820152602001611a96565b50506000910152565b6020815260008251806020840152611ad6816040850160208701611a93565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611b2c57600080fd5b919050565b60008060408385031215611b4457600080fd5b611b4d83611b08565b946020939093013593505050565b600080600060608486031215611b7057600080fd5b611b7984611b08565b9250611b8760208501611b08565b9150604084013590509250925092565b600060208284031215611ba957600080fd5b5035919050565b60008060408385031215611bc357600080fd5b82359150611bd360208401611b08565b90509250929050565b600060208284031215611bee57600080fd5b61088582611b08565b60008060408385031215611c0a57600080fd5b50508035926020909101359150565b60008060408385031215611c2c57600080fd5b611c3583611b08565b9150611bd360208401611b08565b600181811c90821680611c5757607f821691505b602082108103611c90577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104f7576104f7611c96565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b818103818111156104f7576104f7611c96565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611d52816017850160208801611a93565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611d8f816028840160208801611a93565b01602801949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80820281158282048414176104f7576104f7611c96565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081611e1f57611e1f611c96565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220327686ec33f5b163df87c3a7e287dc478a8e4f9109ae8a25f47998a668088bf864736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101c45760003560e01c806370a08231116100f9578063a457c2d711610097578063d539139311610071578063d5391393146103fa578063d547741f14610421578063dd62ed3e14610434578063e63ab1e91461047a57600080fd5b8063a457c2d7146103c1578063a9059cbb146103d4578063ca15c873146103e757600080fd5b80639010d07c116100d35780639010d07c1461033557806391d148541461036d57806395d89b41146103b1578063a217fddf146103b957600080fd5b806370a08231146102e457806379cc67901461031a5780638456cb591461032d57600080fd5b8063313ce567116101665780633f4ba83a116101405780633f4ba83a146102ab57806340c10f19146102b357806342966c68146102c65780635c975abb146102d957600080fd5b8063313ce5671461027657806336568abe14610285578063395093511461029857600080fd5b806318160ddd116101a257806318160ddd1461021957806323b872dd1461022b578063248a9ca31461023e5780632f2ff15d1461026157600080fd5b806301ffc9a7146101c957806306fdde03146101f1578063095ea7b314610206575b600080fd5b6101dc6101d7366004611a51565b6104a1565b60405190151581526020015b60405180910390f35b6101f96104fd565b6040516101e89190611ab7565b6101dc610214366004611b31565b61058f565b6004545b6040519081526020016101e8565b6101dc610239366004611b5b565b6105a7565b61021d61024c366004611b97565b60009081526020819052604090206001015490565b61027461026f366004611bb0565b6105cb565b005b604051601281526020016101e8565b610274610293366004611bb0565b6105f5565b6101dc6102a6366004611b31565b610693565b6102746106df565b6102746102c1366004611b31565b610785565b6102746102d4366004611b97565b6107a7565b60075460ff166101dc565b61021d6102f2366004611bdc565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090205490565b610274610328366004611b31565b6107b4565b6102746107c9565b610348610343366004611bf7565b61086d565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e8565b6101dc61037b366004611bb0565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6101f961088c565b61021d600081565b6101dc6103cf366004611b31565b61089b565b6101dc6103e2366004611b31565b610952565b61021d6103f5366004611b97565b610960565b61021d7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b61027461042f366004611bb0565b610977565b61021d610442366004611c19565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260036020908152604080832093909416825291909152205490565b61021d7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f0000000000000000000000000000000000000000000000000000000014806104f757506104f782610aae565b92915050565b60606005805461050c90611c43565b80601f016020809104026020016040519081016040528092919081815260200182805461053890611c43565b80156105855780601f1061055a57610100808354040283529160200191610585565b820191906000526020600020905b81548152906001019060200180831161056857829003601f168201915b5050505050905090565b60003361059d818585610b45565b5060019392505050565b6000336105b5858285610cc4565b6105c0858585610d81565b506001949350505050565b6000828152602081905260409020600101546105e681610ff1565b6105f08383610ffb565b505050565b73ffffffffffffffffffffffffffffffffffffffff811633146106855760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b61068f828261101d565b5050565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061059d90829086906106da908790611cc5565b610b45565b6107097f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a3361037b565b61077b5760405162461bcd60e51b815260206004820152603960248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20756e706175736500000000000000606482015260840161067c565b61078361103f565b565b678ac7230489e8000081111561079d5761079d611cd8565b61068f82826110bc565b6107b133826111ce565b50565b6107bf823383610cc4565b61068f82826111ce565b6107f37f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a3361037b565b6108655760405162461bcd60e51b815260206004820152603760248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f207061757365000000000000000000606482015260840161067c565b610783611393565b600082815260016020526040812061088590836113ee565b9392505050565b60606006805461050c90611c43565b33600081815260036020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156109455760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161067c565b6105c08286868403610b45565b60003361059d818585610d81565b60008181526001602052604081206104f7906113fa565b60008281526020819052604090206001015461099281610ff1565b6105f0838361101d565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661068f5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610a2e3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006108858373ffffffffffffffffffffffffffffffffffffffff8416611404565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806104f757507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146104f7565b73ffffffffffffffffffffffffffffffffffffffff8316610bcd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8216610c565760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526003602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600360209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610d7b5781811015610d6e5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161067c565b610d7b8484848403610b45565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610e0a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8216610e935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161067c565b610e9e838383611453565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090205481811015610f3a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260026020526040808220858503905591851681529081208054849290610f7e908490611cc5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610fe491815260200190565b60405180910390a3610d7b565b6107b1813361145e565b611005828261099c565b60008281526001602052604090206105f09082610a8c565b6110278282611514565b60008281526001602052604090206105f090826115cb565b6110476115ed565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b73ffffffffffffffffffffffffffffffffffffffff821661111f5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161067c565b61112b60008383611453565b806004600082825461113d9190611cc5565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526002602052604081208054839290611177908490611cc5565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112575760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b61126382600083611453565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260026020526040902054818110156112ff5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161067c565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260026020526040812083830390556004805484929061133b908490611d07565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b61139b61163f565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110923390565b60006108858383611692565b60006104f7825490565b600081815260018301602052604081205461144b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104f7565b5060006104f7565b6105f08383836116bc565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661068f576114b48173ffffffffffffffffffffffffffffffffffffffff166014611735565b6114bf836020611735565b6040516020016114d0929190611d1a565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262461bcd60e51b825261067c91600401611ab7565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff161561068f5760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006108858373ffffffffffffffffffffffffffffffffffffffff841661195e565b60075460ff166107835760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161067c565b60075460ff16156107835760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161067c565b60008260000182815481106116a9576116a9611d9b565b9060005260206000200154905092915050565b60075460ff16156105f05760405162461bcd60e51b815260206004820152602a60248201527f45524332305061757361626c653a20746f6b656e207472616e7366657220776860448201527f696c652070617573656400000000000000000000000000000000000000000000606482015260840161067c565b60606000611744836002611dca565b61174f906002611cc5565b67ffffffffffffffff81111561176757611767611de1565b6040519080825280601f01601f191660200182016040528015611791576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106117c8576117c8611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061182b5761182b611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611867846002611dca565b611872906001611cc5565b90505b600181111561190f577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106118b3576118b3611d9b565b1a60f81b8282815181106118c9576118c9611d9b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361190881611e10565b9050611875565b5083156108855760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161067c565b60008181526001830160205260408120548015611a47576000611982600183611d07565b855490915060009061199690600190611d07565b90508181146119fb5760008660000182815481106119b6576119b6611d9b565b90600052602060002001549050808760000184815481106119d9576119d9611d9b565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a0c57611a0c611e45565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104f7565b60009150506104f7565b600060208284031215611a6357600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461088557600080fd5b60005b83811015611aae578181015183820152602001611a96565b50506000910152565b6020815260008251806020840152611ad6816040850160208701611a93565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611b2c57600080fd5b919050565b60008060408385031215611b4457600080fd5b611b4d83611b08565b946020939093013593505050565b600080600060608486031215611b7057600080fd5b611b7984611b08565b9250611b8760208501611b08565b9150604084013590509250925092565b600060208284031215611ba957600080fd5b5035919050565b60008060408385031215611bc357600080fd5b82359150611bd360208401611b08565b90509250929050565b600060208284031215611bee57600080fd5b61088582611b08565b60008060408385031215611c0a57600080fd5b50508035926020909101359150565b60008060408385031215611c2c57600080fd5b611c3583611b08565b9150611bd360208401611b08565b600181811c90821680611c5757607f821691505b602082108103611c90577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104f7576104f7611c96565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b818103818111156104f7576104f7611c96565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611d52816017850160208801611a93565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611d8f816028840160208801611a93565b01602801949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b80820281158282048414176104f7576104f7611c96565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081611e1f57611e1f611c96565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220327686ec33f5b163df87c3a7e287dc478a8e4f9109ae8a25f47998a668088bf864736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "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(uint256)": { + "details": "Destroys `amount` tokens from the caller. See {ERC20-_burn}." + }, + "burnFrom(address,uint256)": { + "details": "Destroys `amount` tokens from `account`, deducting from the caller's allowance. See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``'s tokens of at least `amount`." + }, + "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`." + }, + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "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` new tokens for `to`. See {ERC20-_mint}. Requirements: - the caller must have the `MINTER_ROLE`." + }, + "name()": { + "details": "Returns the name of the token." + }, + "pause()": { + "details": "Pauses all token transfers. See {ERC20Pausable} and {Pausable-_pause}. Requirements: - the caller must have the `PAUSER_ROLE`." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`. May emit a {RoleRevoked} event." + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event." + }, + "supportsInterface(bytes4)": { + "details": "See {IERC165-supportsInterface}." + }, + "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`." + }, + "unpause()": { + "details": "Unpauses all token transfers. See {ERC20Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 24, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)19_storage)" + }, + { + "astId": 338, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_roleMembers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_struct(AddressSet)2152_storage)" + }, + { + "astId": 666, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_balances", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 672, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_allowances", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 674, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_totalSupply", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 676, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_name", + "offset": 0, + "slot": "5", + "type": "t_string_storage" + }, + { + "astId": 678, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_symbol", + "offset": 0, + "slot": "6", + "type": "t_string_storage" + }, + { + "astId": 560, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_paused", + "offset": 0, + "slot": "7", + "type": "t_bool" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_bytes32)dyn_storage": { + "base": "t_bytes32", + "encoding": "dynamic_array", + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes32,t_struct(AddressSet)2152_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct EnumerableSet.AddressSet)", + "numberOfBytes": "32", + "value": "t_struct(AddressSet)2152_storage" + }, + "t_mapping(t_bytes32,t_struct(RoleData)19_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)19_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(AddressSet)2152_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 2151, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)1851_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(RoleData)19_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 16, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 18, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "adminRole", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + } + ], + "numberOfBytes": "64" + }, + "t_struct(Set)1851_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 1846, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 1850, + "contract": "contracts/helper/DummyERC20.sol:DummyERC20", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} diff --git a/deployments/base_testnet/LPTokenV2.json b/deployments/base_testnet/LPTokenV2.json new file mode 100644 index 00000000..bd710a86 --- /dev/null +++ b/deployments/base_testnet/LPTokenV2.json @@ -0,0 +1,677 @@ +{ + "address": "0xdb5c5A6162115Ce9a188E7D773C4D011F421BbE5", + "abi": [ + { + "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": 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": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "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": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "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": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "name": "initialize", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "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" + } + ], + "transactionHash": "0x9cc5ba1dd15abb27168d0af955b32a15f7fd722bdb166830d04a97b1b7723e10", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xdb5c5A6162115Ce9a188E7D773C4D011F421BbE5", + "transactionIndex": 1, + "gasUsed": "1320355", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc95019a632a0250e2d2afb9c05d47d79619cbcef620937f9ae6fbc2284c75ad7", + "transactionHash": "0x9cc5ba1dd15abb27168d0af955b32a15f7fd722bdb166830d04a97b1b7723e10", + "logs": [], + "blockNumber": 2668381, + "cumulativeGasUsed": "1320355", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"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\":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\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"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\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"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\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"initialize\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"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\":{\"details\":\"Only Swap contracts should initialize and own LPToken contracts.\",\"kind\":\"dev\",\"methods\":{\"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(uint256)\":{\"details\":\"Destroys `amount` tokens from the caller. See {ERC20-_burn}.\"},\"burnFrom(address,uint256)\":{\"details\":\"Destroys `amount` tokens from `account`, deducting from the caller's allowance. See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``'s tokens of at least `amount`.\"},\"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`.\"},\"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.\"},\"initialize(string,string)\":{\"details\":\"The caller of this function will become the owner. A Swap contract should call this in its initializer function.\",\"params\":{\"name\":\"name of this token\",\"symbol\":\"symbol of this token\"}},\"mint(address,uint256)\":{\"details\":\"only owner can call this mint function\",\"params\":{\"amount\":\"amount of tokens to mint\",\"recipient\":\"address of account to receive the tokens\"}},\"name()\":{\"details\":\"Returns the name of the 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.\"},\"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.\"}},\"title\":\"Liquidity Provider Token\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"initialize(string,string)\":{\"notice\":\"Initializes this LPToken contract with the given name and symbol\"},\"mint(address,uint256)\":{\"notice\":\"Mints the given amount of LPToken to the recipient.\"}},\"notice\":\"This token is an ERC20 detailed token with added capability to be minted by the owner. It is used to represent user's shares when providing liquidity to swap contracts.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/LPTokenV2.sol\":\"LPTokenV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50611702806100206000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c806370a08231116100b257806395d89b4111610081578063a9059cbb11610066578063a9059cbb14610292578063dd62ed3e146102a5578063f2fde38b146102eb57600080fd5b806395d89b4114610277578063a457c2d71461027f57600080fd5b806370a08231146101fe578063715018a61461023457806379cc67901461023c5780638da5cb5b1461024f57600080fd5b8063313ce5671161010957806340c10f19116100ee57806340c10f19146101c357806342966c68146101d85780634cd88b76146101eb57600080fd5b8063313ce567146101a157806339509351146101b057600080fd5b806306fdde031461013b578063095ea7b31461015957806318160ddd1461017c57806323b872dd1461018e575b600080fd5b6101436102fe565b6040516101509190611215565b60405180910390f35b61016c6101673660046112aa565b610390565b6040519015158152602001610150565b6035545b604051908152602001610150565b61016c61019c3660046112d4565b6103aa565b60405160128152602001610150565b61016c6101be3660046112aa565b6103ce565b6101d66101d13660046112aa565b61041a565b005b6101d66101e6366004611310565b610485565b61016c6101f9366004611403565b610492565b61018061020c366004611467565b73ffffffffffffffffffffffffffffffffffffffff1660009081526033602052604090205490565b6101d6610625565b6101d661024a3660046112aa565b610639565b60975460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610150565b61014361064e565b61016c61028d3660046112aa565b61065d565b61016c6102a03660046112aa565b610714565b6101806102b3366004611489565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260346020908152604080832093909416825291909152205490565b6101d66102f9366004611467565b610722565b60606036805461030d906114bc565b80601f0160208091040260200160405190810160405280929190818152602001828054610339906114bc565b80156103865780601f1061035b57610100808354040283529160200191610386565b820191906000526020600020905b81548152906001019060200180831161036957829003601f168201915b5050505050905090565b60003361039e8185856107bc565b60019150505b92915050565b6000336103b885828561093c565b6103c38585856109f9565b506001949350505050565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061039e908290869061041590879061153e565b6107bc565b610422610c69565b806000036104775760405162461bcd60e51b815260206004820152601660248201527f4c50546f6b656e3a2063616e6e6f74206d696e7420300000000000000000000060448201526064015b60405180910390fd5b6104818282610cd0565b5050565b61048f3382610de2565b50565b60008054610100900460ff16158080156104b35750600054600160ff909116105b806104cd5750303b1580156104cd575060005460ff166001145b61053f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161046e565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561059d57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6105a5610fa4565b6105af8484611021565b6105b76110b7565b60019150801561061e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5092915050565b61062d610c69565b6106376000611139565b565b61064482338361093c565b6104818282610de2565b60606037805461030d906114bc565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156107075760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161046e565b6103c382868684036107bc565b60003361039e8185856109f9565b61072a610c69565b73ffffffffffffffffffffffffffffffffffffffff81166107b35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161046e565b61048f81611139565b73ffffffffffffffffffffffffffffffffffffffff83166108445760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff82166108cd5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152603460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109f357818110156109e65760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161046e565b6109f384848484036107bc565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a825760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff8216610b0b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161046e565b610b168383836111b0565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604090205481811015610bb25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260336020526040808220858503905591851681529081208054849290610bf690849061153e565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c5c91815260200190565b60405180910390a36109f3565b60975473ffffffffffffffffffffffffffffffffffffffff1633146106375760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161046e565b73ffffffffffffffffffffffffffffffffffffffff8216610d335760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161046e565b610d3f600083836111b0565b8060356000828254610d51919061153e565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604081208054839290610d8b90849061153e565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff8216610e6b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b610e77826000836111b0565b73ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604090205481811015610f135760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff83166000908152603360205260408120838303905560358054849290610f4f908490611551565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161092f565b505050565b600054610100900460ff166106375760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b600054610100900460ff1661109e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b60366110aa83826115b2565b506037610f9f82826115b2565b600054610100900460ff166111345760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b610637335b6097805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b3073ffffffffffffffffffffffffffffffffffffffff831603610f9f5760405162461bcd60e51b815260206004820152601e60248201527f4c50546f6b656e3a2063616e6e6f742073656e6420746f20697473656c660000604482015260640161046e565b600060208083528351808285015260005b8181101561124257858101830151858201604001528201611226565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112a557600080fd5b919050565b600080604083850312156112bd57600080fd5b6112c683611281565b946020939093013593505050565b6000806000606084860312156112e957600080fd5b6112f284611281565b925061130060208501611281565b9150604084013590509250925092565b60006020828403121561132257600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261136957600080fd5b813567ffffffffffffffff8082111561138457611384611329565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156113ca576113ca611329565b816040528381528660208588010111156113e357600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561141657600080fd5b823567ffffffffffffffff8082111561142e57600080fd5b61143a86838701611358565b9350602085013591508082111561145057600080fd5b5061145d85828601611358565b9150509250929050565b60006020828403121561147957600080fd5b61148282611281565b9392505050565b6000806040838503121561149c57600080fd5b6114a583611281565b91506114b360208401611281565b90509250929050565b600181811c908216806114d057607f821691505b602082108103611509577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156103a4576103a461150f565b818103818111156103a4576103a461150f565b601f821115610f9f57600081815260208120601f850160051c8101602086101561158b5750805b601f850160051c820191505b818110156115aa57828155600101611597565b505050505050565b815167ffffffffffffffff8111156115cc576115cc611329565b6115e0816115da84546114bc565b84611564565b602080601f83116001811461163357600084156115fd5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b1785556115aa565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561168057888601518255948401946001909101908401611661565b50858210156116bc57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220c64d54ca2cb162f0d9f61ae1364a723557c1819b6ccbdfadc700c29c8561ee0c64736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101365760003560e01c806370a08231116100b257806395d89b4111610081578063a9059cbb11610066578063a9059cbb14610292578063dd62ed3e146102a5578063f2fde38b146102eb57600080fd5b806395d89b4114610277578063a457c2d71461027f57600080fd5b806370a08231146101fe578063715018a61461023457806379cc67901461023c5780638da5cb5b1461024f57600080fd5b8063313ce5671161010957806340c10f19116100ee57806340c10f19146101c357806342966c68146101d85780634cd88b76146101eb57600080fd5b8063313ce567146101a157806339509351146101b057600080fd5b806306fdde031461013b578063095ea7b31461015957806318160ddd1461017c57806323b872dd1461018e575b600080fd5b6101436102fe565b6040516101509190611215565b60405180910390f35b61016c6101673660046112aa565b610390565b6040519015158152602001610150565b6035545b604051908152602001610150565b61016c61019c3660046112d4565b6103aa565b60405160128152602001610150565b61016c6101be3660046112aa565b6103ce565b6101d66101d13660046112aa565b61041a565b005b6101d66101e6366004611310565b610485565b61016c6101f9366004611403565b610492565b61018061020c366004611467565b73ffffffffffffffffffffffffffffffffffffffff1660009081526033602052604090205490565b6101d6610625565b6101d661024a3660046112aa565b610639565b60975460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610150565b61014361064e565b61016c61028d3660046112aa565b61065d565b61016c6102a03660046112aa565b610714565b6101806102b3366004611489565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260346020908152604080832093909416825291909152205490565b6101d66102f9366004611467565b610722565b60606036805461030d906114bc565b80601f0160208091040260200160405190810160405280929190818152602001828054610339906114bc565b80156103865780601f1061035b57610100808354040283529160200191610386565b820191906000526020600020905b81548152906001019060200180831161036957829003601f168201915b5050505050905090565b60003361039e8185856107bc565b60019150505b92915050565b6000336103b885828561093c565b6103c38585856109f9565b506001949350505050565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061039e908290869061041590879061153e565b6107bc565b610422610c69565b806000036104775760405162461bcd60e51b815260206004820152601660248201527f4c50546f6b656e3a2063616e6e6f74206d696e7420300000000000000000000060448201526064015b60405180910390fd5b6104818282610cd0565b5050565b61048f3382610de2565b50565b60008054610100900460ff16158080156104b35750600054600160ff909116105b806104cd5750303b1580156104cd575060005460ff166001145b61053f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161046e565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561059d57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6105a5610fa4565b6105af8484611021565b6105b76110b7565b60019150801561061e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5092915050565b61062d610c69565b6106376000611139565b565b61064482338361093c565b6104818282610de2565b60606037805461030d906114bc565b33600081815260346020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190838110156107075760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161046e565b6103c382868684036107bc565b60003361039e8185856109f9565b61072a610c69565b73ffffffffffffffffffffffffffffffffffffffff81166107b35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161046e565b61048f81611139565b73ffffffffffffffffffffffffffffffffffffffff83166108445760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff82166108cd5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152603460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146109f357818110156109e65760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161046e565b6109f384848484036107bc565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610a825760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff8216610b0b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161046e565b610b168383836111b0565b73ffffffffffffffffffffffffffffffffffffffff831660009081526033602052604090205481811015610bb25760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260336020526040808220858503905591851681529081208054849290610bf690849061153e565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c5c91815260200190565b60405180910390a36109f3565b60975473ffffffffffffffffffffffffffffffffffffffff1633146106375760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161046e565b73ffffffffffffffffffffffffffffffffffffffff8216610d335760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161046e565b610d3f600083836111b0565b8060356000828254610d51919061153e565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604081208054839290610d8b90849061153e565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff8216610e6b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b610e77826000836111b0565b73ffffffffffffffffffffffffffffffffffffffff821660009081526033602052604090205481811015610f135760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840161046e565b73ffffffffffffffffffffffffffffffffffffffff83166000908152603360205260408120838303905560358054849290610f4f908490611551565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161092f565b505050565b600054610100900460ff166106375760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b600054610100900460ff1661109e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b60366110aa83826115b2565b506037610f9f82826115b2565b600054610100900460ff166111345760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161046e565b610637335b6097805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b3073ffffffffffffffffffffffffffffffffffffffff831603610f9f5760405162461bcd60e51b815260206004820152601e60248201527f4c50546f6b656e3a2063616e6e6f742073656e6420746f20697473656c660000604482015260640161046e565b600060208083528351808285015260005b8181101561124257858101830151858201604001528201611226565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112a557600080fd5b919050565b600080604083850312156112bd57600080fd5b6112c683611281565b946020939093013593505050565b6000806000606084860312156112e957600080fd5b6112f284611281565b925061130060208501611281565b9150604084013590509250925092565b60006020828403121561132257600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261136957600080fd5b813567ffffffffffffffff8082111561138457611384611329565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156113ca576113ca611329565b816040528381528660208588010111156113e357600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561141657600080fd5b823567ffffffffffffffff8082111561142e57600080fd5b61143a86838701611358565b9350602085013591508082111561145057600080fd5b5061145d85828601611358565b9150509250929050565b60006020828403121561147957600080fd5b61148282611281565b9392505050565b6000806040838503121561149c57600080fd5b6114a583611281565b91506114b360208401611281565b90509250929050565b600181811c908216806114d057607f821691505b602082108103611509577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156103a4576103a461150f565b818103818111156103a4576103a461150f565b601f821115610f9f57600081815260208120601f850160051c8101602086101561158b5750805b601f850160051c820191505b818110156115aa57828155600101611597565b505050505050565b815167ffffffffffffffff8111156115cc576115cc611329565b6115e0816115da84546114bc565b84611564565b602080601f83116001811461163357600084156115fd5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b1785556115aa565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561168057888601518255948401946001909101908401611661565b50858210156116bc57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220c64d54ca2cb162f0d9f61ae1364a723557c1819b6ccbdfadc700c29c8561ee0c64736f6c63430008110033", + "devdoc": { + "details": "Only Swap contracts should initialize and own LPToken contracts.", + "kind": "dev", + "methods": { + "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(uint256)": { + "details": "Destroys `amount` tokens from the caller. See {ERC20-_burn}." + }, + "burnFrom(address,uint256)": { + "details": "Destroys `amount` tokens from `account`, deducting from the caller's allowance. See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for ``accounts``'s tokens of at least `amount`." + }, + "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`." + }, + "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." + }, + "initialize(string,string)": { + "details": "The caller of this function will become the owner. A Swap contract should call this in its initializer function.", + "params": { + "name": "name of this token", + "symbol": "symbol of this token" + } + }, + "mint(address,uint256)": { + "details": "only owner can call this mint function", + "params": { + "amount": "amount of tokens to mint", + "recipient": "address of account to receive the tokens" + } + }, + "name()": { + "details": "Returns the name of the 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." + }, + "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." + } + }, + "title": "Liquidity Provider Token", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "initialize(string,string)": { + "notice": "Initializes this LPToken contract with the given name and symbol" + }, + "mint(address,uint256)": { + "notice": "Mints the given amount of LPToken to the recipient." + } + }, + "notice": "This token is an ERC20 detailed token with added capability to be minted by the owner. It is used to represent user's shares when providing liquidity to swap contracts.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1654, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 1657, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 3046, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 2003, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_balances", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 2009, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_allowances", + "offset": 0, + "slot": "52", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 2011, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_totalSupply", + "offset": 0, + "slot": "53", + "type": "t_uint256" + }, + { + "astId": 2013, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_name", + "offset": 0, + "slot": "54", + "type": "t_string_storage" + }, + { + "astId": 2015, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_symbol", + "offset": 0, + "slot": "55", + "type": "t_string_storage" + }, + { + "astId": 2594, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "__gap", + "offset": 0, + "slot": "56", + "type": "t_array(t_uint256)45_storage" + }, + { + "astId": 2736, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "__gap", + "offset": 0, + "slot": "101", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 1526, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "_owner", + "offset": 0, + "slot": "151", + "type": "t_address" + }, + { + "astId": 1646, + "contract": "contracts/LPTokenV2.sol:LPTokenV2", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)45_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/MasterRegistry.json b/deployments/base_testnet/MasterRegistry.json new file mode 100644 index 00000000..5f505b96 --- /dev/null +++ b/deployments/base_testnet/MasterRegistry.json @@ -0,0 +1,745 @@ +{ + "address": "0x9cDeF6e33687F438808766fC133b2E9d1A16AD57", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "registryAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "version", + "type": "uint256" + } + ], + "name": "AddRegistry", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SADDLE_MANAGER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "registryName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "registryAddress", + "type": "address" + } + ], + "name": "addRegistry", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "calls", + "type": "bytes[]" + }, + { + "internalType": "bool", + "name": "revertOnFail", + "type": "bool" + } + ], + "name": "batch", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "registryAddress", + "type": "address" + } + ], + "name": "resolveAddressToRegistryData", + "outputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "version", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isLatest", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "version", + "type": "uint256" + } + ], + "name": "resolveNameAndVersionToAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "resolveNameToAllAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "resolveNameToLatestAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xb074be72a4414cf226e2c08b8017e00f224b40ada6c83ef2f4150ac0eaf7ea85", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0x9cDeF6e33687F438808766fC133b2E9d1A16AD57", + "transactionIndex": 1, + "gasUsed": "1276488", + "logsBloom": "0x00000004000400000000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000800000000000000000000000002000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000001000000000000000000020000000000000000000000000000000000000000100000000000020000000000000000000000000000000000000000000000080000000000000000000", + "blockHash": "0xf7ead17ba9b3762abb62483d30f01c0549a3b4bbc46d16e7bdee3fb150121e14", + "transactionHash": "0xb074be72a4414cf226e2c08b8017e00f224b40ada6c83ef2f4150ac0eaf7ea85", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 2717063, + "transactionHash": "0xb074be72a4414cf226e2c08b8017e00f224b40ada6c83ef2f4150ac0eaf7ea85", + "address": "0x9cDeF6e33687F438808766fC133b2E9d1A16AD57", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xf7ead17ba9b3762abb62483d30f01c0549a3b4bbc46d16e7bdee3fb150121e14" + }, + { + "transactionIndex": 1, + "blockNumber": 2717063, + "transactionHash": "0xb074be72a4414cf226e2c08b8017e00f224b40ada6c83ef2f4150ac0eaf7ea85", + "address": "0x9cDeF6e33687F438808766fC133b2E9d1A16AD57", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0xe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0xf7ead17ba9b3762abb62483d30f01c0549a3b4bbc46d16e7bdee3fb150121e14" + } + ], + "blockNumber": 2717063, + "cumulativeGasUsed": "1276488", + "status": 1, + "byzantium": true + }, + "args": ["0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34"], + "numDeployments": 1, + "solcInputHash": "bc3a64a5cffb1e8de0dbf9fb306e4f9f", + "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"registryAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"AddRegistry\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SADDLE_MANAGER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"registryName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"registryAddress\",\"type\":\"address\"}],\"name\":\"addRegistry\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"calls\",\"type\":\"bytes[]\"},{\"internalType\":\"bool\",\"name\":\"revertOnFail\",\"type\":\"bool\"}],\"name\":\"batch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"registryAddress\",\"type\":\"address\"}],\"name\":\"resolveAddressToRegistryData\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isLatest\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"resolveNameAndVersionToAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"resolveNameToAllAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"name\",\"type\":\"bytes32\"}],\"name\":\"resolveNameToLatestAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"AddRegistry(bytes32,address,uint256)\":{\"params\":{\"name\":\"address of the added pool\",\"registryAddress\":\"address of the registry\",\"version\":\"version of the registry\"}}},\"kind\":\"dev\",\"methods\":{\"addRegistry(bytes32,address)\":{\"params\":{\"registryAddress\":\"address of the new registry\",\"registryName\":\"name for the registry\"}},\"batch(bytes[],bool)\":{\"params\":{\"calls\":\"An array of inputs for each call.\",\"revertOnFail\":\"If True then reverts after a failed call and stops doing further calls.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"resolveAddressToRegistryData(address)\":{\"params\":{\"registryAddress\":\"address of a registry you want to resolve\"},\"returns\":{\"isLatest\":\"boolean flag of whether the given address is the latest version of the given registries with matching name\",\"name\":\"name of the resolved registry\",\"version\":\"version of the resolved registry\"}},\"resolveNameAndVersionToAddress(bytes32,uint256)\":{\"params\":{\"name\":\"address of the registry you want to resolve to\",\"version\":\"version of the registry you want to resolve to\"}},\"resolveNameToAllAddresses(bytes32)\":{\"params\":{\"name\":\"name for the registry\"},\"returns\":{\"_0\":\"address address of the latest registry with the matching name\"}},\"resolveNameToLatestAddress(bytes32)\":{\"params\":{\"name\":\"name for the registry\"},\"returns\":{\"_0\":\"address address of the latest registry with the matching name\"}},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"title\":\"MasterRegistry\",\"version\":1},\"userdoc\":{\"events\":{\"AddRegistry(bytes32,address,uint256)\":{\"notice\":\"Add a new registry entry to the master list.\"}},\"kind\":\"user\",\"methods\":{\"SADDLE_MANAGER_ROLE()\":{\"notice\":\"Role responsible for adding registries.\"},\"addRegistry(bytes32,address)\":{\"notice\":\"Add a new registry entry to the master list.\"},\"batch(bytes[],bool)\":{\"notice\":\"Allows batched call to self (this contract).\"},\"resolveAddressToRegistryData(address)\":{\"notice\":\"Resolves an address to registry entry data.\"},\"resolveNameAndVersionToAddress(bytes32,uint256)\":{\"notice\":\"Resolves a name and version to an address. Reverts if there is no registry with given name and version.\"},\"resolveNameToAllAddresses(bytes32)\":{\"notice\":\"Resolves a name to an array of all addresses. Reverts if no match is found.\"},\"resolveNameToLatestAddress(bytes32)\":{\"notice\":\"Resolves a name to the latest registry address. Reverts if no match is found.\"}},\"notice\":\"This contract holds list of other registries or contracts and its historical versions.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/registries/MasterRegistry.sol\":\"MasterRegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/EnumerableSet.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using Address for address;\\n\\n struct RoleData {\\n EnumerableSet.AddressSet members;\\n bytes32 adminRole;\\n }\\n\\n mapping (bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view returns (bool) {\\n return _roles[role].members.contains(account);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\\n return _roles[role].members.length();\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\\n return _roles[role].members.at(index);\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to grant\\\");\\n\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to revoke\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\\n _roles[role].adminRole = adminRole;\\n }\\n\\n function _grantRole(bytes32 role, address account) private {\\n if (_roles[role].members.add(account)) {\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n function _revokeRole(bytes32 role, address account) private {\\n if (_roles[role].members.remove(account)) {\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc155a2f7837603d69a13cfa481eb5e7f5e02cb77e2ec9edbac30986db37988\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x1562cd9922fbf739edfb979f506809e2743789cbde3177515542161c3d04b164\",\"license\":\"MIT\"},\"contracts/helper/BaseBoringBatchable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.6.12;\\npragma experimental ABIEncoderV2;\\n\\n// solhint-disable avoid-low-level-calls\\n// solhint-disable no-inline-assembly\\n\\n// Audit on 5-Jan-2021 by Keno and BoringCrypto\\n// WARNING!!!\\n// Combining BoringBatchable with msg.value can cause double spending issues\\n// https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong/\\n\\ncontract BaseBoringBatchable {\\n /// @dev Helper function to extract a useful revert message from a failed call.\\n /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.\\n function _getRevertMsg(bytes memory _returnData)\\n internal\\n pure\\n returns (string memory)\\n {\\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\\n if (_returnData.length < 68) return \\\"Transaction reverted silently\\\";\\n\\n assembly {\\n // Slice the sighash.\\n _returnData := add(_returnData, 0x04)\\n }\\n return abi.decode(_returnData, (string)); // All that remains is the revert string\\n }\\n\\n /// @notice Allows batched call to self (this contract).\\n /// @param calls An array of inputs for each call.\\n /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.\\n // F1: External is ok here because this is the batch function, adding it to a batch makes no sense\\n // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value\\n // C3: The length of the loop is fully under user control, so can't be exploited\\n // C7: Delegatecall is only used on the same contract, so it's safe\\n function batch(bytes[] calldata calls, bool revertOnFail) external payable {\\n for (uint256 i = 0; i < calls.length; i++) {\\n (bool success, bytes memory result) = address(this).delegatecall(\\n calls[i]\\n );\\n if (!success && revertOnFail) {\\n revert(_getRevertMsg(result));\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x95f34c0ce5cd71071698709dd23eea9b6031fe973be9d6f53f9f08452a444d66\",\"license\":\"MIT\"},\"contracts/interfaces/IMasterRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\ninterface IMasterRegistry {\\n /* Structs */\\n\\n struct ReverseRegistryData {\\n bytes32 name;\\n uint256 version;\\n }\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param registryName name for the registry\\n * @param registryAddress address of the new registry\\n */\\n function addRegistry(bytes32 registryName, address registryAddress)\\n external\\n payable;\\n\\n /**\\n * @notice Resolves a name to the latest registry address. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToLatestAddress(bytes32 name)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name and version to an address. Reverts if there is no registry with given name and version.\\n * @param name address of the registry you want to resolve to\\n * @param version version of the registry you want to resolve to\\n */\\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name to an array of all addresses. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToAllAddresses(bytes32 name)\\n external\\n view\\n returns (address[] memory);\\n\\n /**\\n * @notice Resolves an address to registry entry data.\\n * @param registryAddress address of a registry you want to resolve\\n * @return name name of the resolved registry\\n * @return version version of the resolved registry\\n * @return isLatest boolean flag of whether the given address is the latest version of the given registries with\\n * matching name\\n */\\n function resolveAddressToRegistryData(address registryAddress)\\n external\\n view\\n returns (\\n bytes32 name,\\n uint256 version,\\n bool isLatest\\n );\\n}\\n\",\"keccak256\":\"0x0e403d7e259003f3826b3009ae3e39344706d7af8a0a5bd48ba45a6ca978226b\",\"license\":\"MIT\"},\"contracts/registries/MasterRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"../helper/BaseBoringBatchable.sol\\\";\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\n\\n/**\\n * @title MasterRegistry\\n * @notice This contract holds list of other registries or contracts and its historical versions.\\n */\\ncontract MasterRegistry is AccessControl, IMasterRegistry, BaseBoringBatchable {\\n /// @notice Role responsible for adding registries.\\n bytes32 public constant SADDLE_MANAGER_ROLE =\\n keccak256(\\\"SADDLE_MANAGER_ROLE\\\");\\n\\n mapping(bytes32 => address[]) private registryMap;\\n mapping(address => ReverseRegistryData) private reverseRegistry;\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param name address of the added pool\\n * @param registryAddress address of the registry\\n * @param version version of the registry\\n */\\n event AddRegistry(\\n bytes32 indexed name,\\n address registryAddress,\\n uint256 version\\n );\\n\\n constructor(address admin) public {\\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\\n }\\n\\n /// @inheritdoc IMasterRegistry\\n function addRegistry(bytes32 registryName, address registryAddress)\\n external\\n payable\\n override\\n {\\n require(\\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\\n \\\"MR: msg.sender is not allowed\\\"\\n );\\n require(registryName != 0, \\\"MR: name cannot be empty\\\");\\n require(registryAddress != address(0), \\\"MR: address cannot be empty\\\");\\n\\n address[] storage registry = registryMap[registryName];\\n uint256 version = registry.length;\\n registry.push(registryAddress);\\n require(\\n reverseRegistry[registryAddress].name == 0,\\n \\\"MR: duplicate registry address\\\"\\n );\\n reverseRegistry[registryAddress] = ReverseRegistryData(\\n registryName,\\n version\\n );\\n\\n emit AddRegistry(registryName, registryAddress, version);\\n }\\n\\n /// @inheritdoc IMasterRegistry\\n function resolveNameToLatestAddress(bytes32 name)\\n external\\n view\\n override\\n returns (address)\\n {\\n address[] storage registry = registryMap[name];\\n uint256 length = registry.length;\\n require(length > 0, \\\"MR: no match found for name\\\");\\n return registry[length - 1];\\n }\\n\\n /// @inheritdoc IMasterRegistry\\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\\n external\\n view\\n override\\n returns (address)\\n {\\n address[] storage registry = registryMap[name];\\n require(\\n version < registry.length,\\n \\\"MR: no match found for name and version\\\"\\n );\\n return registry[version];\\n }\\n\\n /// @inheritdoc IMasterRegistry\\n function resolveNameToAllAddresses(bytes32 name)\\n external\\n view\\n override\\n returns (address[] memory)\\n {\\n address[] storage registry = registryMap[name];\\n require(registry.length > 0, \\\"MR: no match found for name\\\");\\n return registry;\\n }\\n\\n /// @inheritdoc IMasterRegistry\\n function resolveAddressToRegistryData(address registryAddress)\\n external\\n view\\n override\\n returns (\\n bytes32 name,\\n uint256 version,\\n bool isLatest\\n )\\n {\\n ReverseRegistryData memory data = reverseRegistry[registryAddress];\\n require(data.name != 0, \\\"MR: no match found for address\\\");\\n name = data.name;\\n version = data.version;\\n uint256 length = registryMap[name].length;\\n require(length > 0, \\\"MR: no version found for address\\\");\\n isLatest = version == length - 1;\\n }\\n}\\n\",\"keccak256\":\"0xc28c337e4486a0c1c20093655db19435bd2f0b507c23b50437bc030a8ce1af7e\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200155138038062001551833981016040819052620000349162000188565b6200004160008262000074565b6200006d7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd3362000074565b50620001b8565b62000080828262000084565b5050565b600082815260208181526040909120620000a9918390620008ba620000fd821b17901c565b156200008057620000b96200011d565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000114836001600160a01b03841662000121565b90505b92915050565b3390565b60006200012f838362000170565b620001675750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000117565b50600062000117565b60009081526001919091016020526040902054151590565b6000602082840312156200019a578081fd5b81516001600160a01b0381168114620001b1578182fd5b9392505050565b61138980620001c86000396000f3fe6080604052600436106100e85760003560e01c806391d148541161008a578063ca15c87311610059578063ca15c87314610285578063d2423b51146102a5578063d547741f146102b8578063f67ff842146102d8576100e8565b806391d14854146101f4578063a0fc52a314610221578063a217fddf14610241578063a67d236b14610256576100e8565b806336568abe116100c657806336568abe146101725780633705f625146101925780636d2f2246146101bf5780639010d07c146101d4576100e8565b806303aa6d38146100ed578063248a9ca3146101235780632f2ff15d14610150575b600080fd5b3480156100f957600080fd5b5061010d610108366004610d06565b6102eb565b60405161011a9190610e96565b60405180910390f35b34801561012f57600080fd5b5061014361013e366004610d06565b610390565b60405161011a9190610efb565b34801561015c57600080fd5b5061017061016b366004610d1e565b6103a5565b005b34801561017e57600080fd5b5061017061018d366004610d1e565b6103ed565b34801561019e57600080fd5b506101b26101ad366004610d06565b610449565b60405161011a9190610e4f565b3480156101cb57600080fd5b506101436104af565b3480156101e057600080fd5b506101b26101ef366004610d65565b6104d3565b34801561020057600080fd5b5061021461020f366004610d1e565b6104f4565b60405161011a9190610ef0565b34801561022d57600080fd5b506101b261023c366004610d65565b61050c565b34801561024d57600080fd5b50610143610546565b34801561026257600080fd5b50610276610271366004610c47565b61054b565b60405161011a93929190610f04565b34801561029157600080fd5b506101436102a0366004610d06565b610603565b6101706102b3366004610c82565b61061a565b3480156102c457600080fd5b506101706102d3366004610d1e565b6106dd565b6101706102e6366004610d1e565b610717565b60008181526001602052604090208054606091906103245760405162461bcd60e51b815260040161031b90611197565b60405180910390fd5b80546040805160208084028201810190925282815291839183018282801561038257602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610357575b50505050509150505b919050565b60009081526020819052604090206002015490565b6000828152602081905260409020600201546103c39061020f6108dc565b6103df5760405162461bcd60e51b815260040161031b90610fca565b6103e982826108e0565b5050565b6103f56108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461043f5760405162461bcd60e51b815260040161031b90611260565b6103e98282610963565b60008181526001602052604081208054806104765760405162461bcd60e51b815260040161031b90611197565b81600182038154811061048557fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16949350505050565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b60008281526020819052604081206104eb90836109e6565b90505b92915050565b60008281526020819052604081206104eb90836109f2565b60008281526001602052604081208054831061053a5760405162461bcd60e51b815260040161031b906111ce565b80838154811061048557fe5b600081565b6000806000610558610c30565b5073ffffffffffffffffffffffffffffffffffffffff841660009081526002602090815260409182902082518084019093528054808452600190910154918301919091526105b85760405162461bcd60e51b815260040161031b90611129565b8051602080830151600083815260019092526040909120549195509350806105f25760405162461bcd60e51b815260040161031b9061122b565b600181038414925050509193909250565b60008181526020819052604081206104ee90610a14565b60005b828110156106d757600060603086868581811061063657fe5b905060200281019061064891906112bd565b604051610656929190610e3f565b600060405180830381855af49150503d8060008114610691576040519150601f19603f3d011682016040523d82523d6000602084013e610696565b606091505b5091509150811580156106a65750835b156106cd576106b481610a1f565b60405162461bcd60e51b815260040161031b9190610f1c565b505060010161061d565b50505050565b6000828152602081905260409020600201546106fb9061020f6108dc565b61043f5760405162461bcd60e51b815260040161031b906110cc565b6107417fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd336104f4565b61075d5760405162461bcd60e51b815260040161031b90611027565b8161077a5760405162461bcd60e51b815260040161031b90611095565b73ffffffffffffffffffffffffffffffffffffffff81166107ad5760405162461bcd60e51b815260040161031b90611160565b600082815260016020818152604080842080549384018155808552828520840180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88169081179091558552600290925290922054156108365760405162461bcd60e51b815260040161031b9061105e565b604080518082018252858152602080820184815273ffffffffffffffffffffffffffffffffffffffff8716600090815260029092529083902091518255516001909101555184907fb548fd55460ebbfd131d635d9804c0edf1598b692d074d441d89205f5f2f1f53906108ac9086908590610e70565b60405180910390a250505050565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610a7f565b3390565b60008281526020819052604090206108f890826108ba565b156103e9576109056108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260208190526040902061097b9082610ac9565b156103e9576109886108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60006104eb8383610aeb565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610b30565b60006104ee82610b48565b6060604482511015610a65575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015261038b565b600482019150818060200190518101906104ee9190610d86565b6000610a8b8383610b30565b610ac1575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104ee565b5060006104ee565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610b4c565b81546000908210610b0e5760405162461bcd60e51b815260040161031b90610f6d565b826000018281548110610b1d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b60008181526001830160205260408120548015610c265783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8083019190810190600090879083908110610b9d57fe5b9060005260206000200154905080876000018481548110610bba57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080610bea57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506104ee565b60009150506104ee565b604080518082019091526000808252602082015290565b600060208284031215610c58578081fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610c7b578182fd5b9392505050565b600080600060408486031215610c96578182fd5b833567ffffffffffffffff80821115610cad578384fd5b818601915086601f830112610cc0578384fd5b813581811115610cce578485fd5b8760208083028501011115610ce1578485fd5b602092830195509350508401358015158114610cfb578182fd5b809150509250925092565b600060208284031215610d17578081fd5b5035919050565b60008060408385031215610d30578182fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff81168114610d5a578182fd5b809150509250929050565b60008060408385031215610d77578182fd5b50508035926020909101359150565b600060208284031215610d97578081fd5b815167ffffffffffffffff80821115610dae578283fd5b818401915084601f830112610dc1578283fd5b815181811115610dcf578384fd5b60405160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401168201018181108482111715610e0d578586fd5b604052818152838201602001871015610e24578485fd5b610e35826020830160208701611327565b9695505050505050565b6000828483379101908152919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015610ee457835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610eb2565b50909695505050505050565b901515815260200190565b90815260200190565b92835260208301919091521515604082015260600190565b6000602082528251806020840152610f3b816040850160208701611327565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601d908201527f4d523a206d73672e73656e646572206973206e6f7420616c6c6f776564000000604082015260600190565b6020808252601e908201527f4d523a206475706c696361746520726567697374727920616464726573730000604082015260600190565b60208082526018908201527f4d523a206e616d652063616e6e6f7420626520656d7074790000000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252601e908201527f4d523a206e6f206d6174636820666f756e6420666f7220616464726573730000604082015260600190565b6020808252601b908201527f4d523a20616464726573732063616e6e6f7420626520656d7074790000000000604082015260600190565b6020808252601b908201527f4d523a206e6f206d6174636820666f756e6420666f72206e616d650000000000604082015260600190565b60208082526027908201527f4d523a206e6f206d6174636820666f756e6420666f72206e616d6520616e642060408201527f76657273696f6e00000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4d523a206e6f2076657273696f6e20666f756e6420666f722061646472657373604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126112f1578283fd5b83018035915067ffffffffffffffff82111561130b578283fd5b60200191503681900382131561132057600080fd5b9250929050565b60005b8381101561134257818101518382015260200161132a565b838111156106d7575050600091015256fea26469706673582212202ea1ec19e00634076dc03e1d613a37a25a0f738d09e74ce53da6efa5619ed50e64736f6c634300060c0033", + "deployedBytecode": "0x6080604052600436106100e85760003560e01c806391d148541161008a578063ca15c87311610059578063ca15c87314610285578063d2423b51146102a5578063d547741f146102b8578063f67ff842146102d8576100e8565b806391d14854146101f4578063a0fc52a314610221578063a217fddf14610241578063a67d236b14610256576100e8565b806336568abe116100c657806336568abe146101725780633705f625146101925780636d2f2246146101bf5780639010d07c146101d4576100e8565b806303aa6d38146100ed578063248a9ca3146101235780632f2ff15d14610150575b600080fd5b3480156100f957600080fd5b5061010d610108366004610d06565b6102eb565b60405161011a9190610e96565b60405180910390f35b34801561012f57600080fd5b5061014361013e366004610d06565b610390565b60405161011a9190610efb565b34801561015c57600080fd5b5061017061016b366004610d1e565b6103a5565b005b34801561017e57600080fd5b5061017061018d366004610d1e565b6103ed565b34801561019e57600080fd5b506101b26101ad366004610d06565b610449565b60405161011a9190610e4f565b3480156101cb57600080fd5b506101436104af565b3480156101e057600080fd5b506101b26101ef366004610d65565b6104d3565b34801561020057600080fd5b5061021461020f366004610d1e565b6104f4565b60405161011a9190610ef0565b34801561022d57600080fd5b506101b261023c366004610d65565b61050c565b34801561024d57600080fd5b50610143610546565b34801561026257600080fd5b50610276610271366004610c47565b61054b565b60405161011a93929190610f04565b34801561029157600080fd5b506101436102a0366004610d06565b610603565b6101706102b3366004610c82565b61061a565b3480156102c457600080fd5b506101706102d3366004610d1e565b6106dd565b6101706102e6366004610d1e565b610717565b60008181526001602052604090208054606091906103245760405162461bcd60e51b815260040161031b90611197565b60405180910390fd5b80546040805160208084028201810190925282815291839183018282801561038257602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610357575b50505050509150505b919050565b60009081526020819052604090206002015490565b6000828152602081905260409020600201546103c39061020f6108dc565b6103df5760405162461bcd60e51b815260040161031b90610fca565b6103e982826108e0565b5050565b6103f56108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461043f5760405162461bcd60e51b815260040161031b90611260565b6103e98282610963565b60008181526001602052604081208054806104765760405162461bcd60e51b815260040161031b90611197565b81600182038154811061048557fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16949350505050565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b60008281526020819052604081206104eb90836109e6565b90505b92915050565b60008281526020819052604081206104eb90836109f2565b60008281526001602052604081208054831061053a5760405162461bcd60e51b815260040161031b906111ce565b80838154811061048557fe5b600081565b6000806000610558610c30565b5073ffffffffffffffffffffffffffffffffffffffff841660009081526002602090815260409182902082518084019093528054808452600190910154918301919091526105b85760405162461bcd60e51b815260040161031b90611129565b8051602080830151600083815260019092526040909120549195509350806105f25760405162461bcd60e51b815260040161031b9061122b565b600181038414925050509193909250565b60008181526020819052604081206104ee90610a14565b60005b828110156106d757600060603086868581811061063657fe5b905060200281019061064891906112bd565b604051610656929190610e3f565b600060405180830381855af49150503d8060008114610691576040519150601f19603f3d011682016040523d82523d6000602084013e610696565b606091505b5091509150811580156106a65750835b156106cd576106b481610a1f565b60405162461bcd60e51b815260040161031b9190610f1c565b505060010161061d565b50505050565b6000828152602081905260409020600201546106fb9061020f6108dc565b61043f5760405162461bcd60e51b815260040161031b906110cc565b6107417fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd336104f4565b61075d5760405162461bcd60e51b815260040161031b90611027565b8161077a5760405162461bcd60e51b815260040161031b90611095565b73ffffffffffffffffffffffffffffffffffffffff81166107ad5760405162461bcd60e51b815260040161031b90611160565b600082815260016020818152604080842080549384018155808552828520840180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88169081179091558552600290925290922054156108365760405162461bcd60e51b815260040161031b9061105e565b604080518082018252858152602080820184815273ffffffffffffffffffffffffffffffffffffffff8716600090815260029092529083902091518255516001909101555184907fb548fd55460ebbfd131d635d9804c0edf1598b692d074d441d89205f5f2f1f53906108ac9086908590610e70565b60405180910390a250505050565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610a7f565b3390565b60008281526020819052604090206108f890826108ba565b156103e9576109056108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260208190526040902061097b9082610ac9565b156103e9576109886108dc565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60006104eb8383610aeb565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610b30565b60006104ee82610b48565b6060604482511015610a65575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015261038b565b600482019150818060200190518101906104ee9190610d86565b6000610a8b8383610b30565b610ac1575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104ee565b5060006104ee565b60006104eb8373ffffffffffffffffffffffffffffffffffffffff8416610b4c565b81546000908210610b0e5760405162461bcd60e51b815260040161031b90610f6d565b826000018281548110610b1d57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b60008181526001830160205260408120548015610c265783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8083019190810190600090879083908110610b9d57fe5b9060005260206000200154905080876000018481548110610bba57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080610bea57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506104ee565b60009150506104ee565b604080518082019091526000808252602082015290565b600060208284031215610c58578081fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610c7b578182fd5b9392505050565b600080600060408486031215610c96578182fd5b833567ffffffffffffffff80821115610cad578384fd5b818601915086601f830112610cc0578384fd5b813581811115610cce578485fd5b8760208083028501011115610ce1578485fd5b602092830195509350508401358015158114610cfb578182fd5b809150509250925092565b600060208284031215610d17578081fd5b5035919050565b60008060408385031215610d30578182fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff81168114610d5a578182fd5b809150509250929050565b60008060408385031215610d77578182fd5b50508035926020909101359150565b600060208284031215610d97578081fd5b815167ffffffffffffffff80821115610dae578283fd5b818401915084601f830112610dc1578283fd5b815181811115610dcf578384fd5b60405160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401168201018181108482111715610e0d578586fd5b604052818152838201602001871015610e24578485fd5b610e35826020830160208701611327565b9695505050505050565b6000828483379101908152919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015610ee457835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101610eb2565b50909695505050505050565b901515815260200190565b90815260200190565b92835260208301919091521515604082015260600190565b6000602082528251806020840152610f3b816040850160208701611327565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601d908201527f4d523a206d73672e73656e646572206973206e6f7420616c6c6f776564000000604082015260600190565b6020808252601e908201527f4d523a206475706c696361746520726567697374727920616464726573730000604082015260600190565b60208082526018908201527f4d523a206e616d652063616e6e6f7420626520656d7074790000000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252601e908201527f4d523a206e6f206d6174636820666f756e6420666f7220616464726573730000604082015260600190565b6020808252601b908201527f4d523a20616464726573732063616e6e6f7420626520656d7074790000000000604082015260600190565b6020808252601b908201527f4d523a206e6f206d6174636820666f756e6420666f72206e616d650000000000604082015260600190565b60208082526027908201527f4d523a206e6f206d6174636820666f756e6420666f72206e616d6520616e642060408201527f76657273696f6e00000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4d523a206e6f2076657273696f6e20666f756e6420666f722061646472657373604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126112f1578283fd5b83018035915067ffffffffffffffff82111561130b578283fd5b60200191503681900382131561132057600080fd5b9250929050565b60005b8381101561134257818101518382015260200161132a565b838111156106d7575050600091015256fea26469706673582212202ea1ec19e00634076dc03e1d613a37a25a0f738d09e74ce53da6efa5619ed50e64736f6c634300060c0033", + "devdoc": { + "events": { + "AddRegistry(bytes32,address,uint256)": { + "params": { + "name": "address of the added pool", + "registryAddress": "address of the registry", + "version": "version of the registry" + } + } + }, + "kind": "dev", + "methods": { + "addRegistry(bytes32,address)": { + "params": { + "registryAddress": "address of the new registry", + "registryName": "name for the registry" + } + }, + "batch(bytes[],bool)": { + "params": { + "calls": "An array of inputs for each call.", + "revertOnFail": "If True then reverts after a failed call and stops doing further calls." + } + }, + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`." + }, + "resolveAddressToRegistryData(address)": { + "params": { + "registryAddress": "address of a registry you want to resolve" + }, + "returns": { + "isLatest": "boolean flag of whether the given address is the latest version of the given registries with matching name", + "name": "name of the resolved registry", + "version": "version of the resolved registry" + } + }, + "resolveNameAndVersionToAddress(bytes32,uint256)": { + "params": { + "name": "address of the registry you want to resolve to", + "version": "version of the registry you want to resolve to" + } + }, + "resolveNameToAllAddresses(bytes32)": { + "params": { + "name": "name for the registry" + }, + "returns": { + "_0": "address address of the latest registry with the matching name" + } + }, + "resolveNameToLatestAddress(bytes32)": { + "params": { + "name": "name for the registry" + }, + "returns": { + "_0": "address address of the latest registry with the matching name" + } + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role." + } + }, + "title": "MasterRegistry", + "version": 1 + }, + "userdoc": { + "events": { + "AddRegistry(bytes32,address,uint256)": { + "notice": "Add a new registry entry to the master list." + } + }, + "kind": "user", + "methods": { + "SADDLE_MANAGER_ROLE()": { + "notice": "Role responsible for adding registries." + }, + "addRegistry(bytes32,address)": { + "notice": "Add a new registry entry to the master list." + }, + "batch(bytes[],bool)": { + "notice": "Allows batched call to self (this contract)." + }, + "resolveAddressToRegistryData(address)": { + "notice": "Resolves an address to registry entry data." + }, + "resolveNameAndVersionToAddress(bytes32,uint256)": { + "notice": "Resolves a name and version to an address. Reverts if there is no registry with given name and version." + }, + "resolveNameToAllAddresses(bytes32)": { + "notice": "Resolves a name to an array of all addresses. Reverts if no match is found." + }, + "resolveNameToLatestAddress(bytes32)": { + "notice": "Resolves a name to the latest registry address. Reverts if no match is found." + } + }, + "notice": "This contract holds list of other registries or contracts and its historical versions.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1726, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)" + }, + { + "astId": 33439, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "registryMap", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_array(t_address)dyn_storage)" + }, + { + "astId": 33443, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "reverseRegistry", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_struct(ReverseRegistryData)24565_storage)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "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_address,t_struct(ReverseRegistryData)24565_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct IMasterRegistry.ReverseRegistryData)", + "numberOfBytes": "32", + "value": "t_struct(ReverseRegistryData)24565_storage" + }, + "t_mapping(t_bytes32,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)1722_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)5815_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 5814, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)5550_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(ReverseRegistryData)24565_storage": { + "encoding": "inplace", + "label": "struct IMasterRegistry.ReverseRegistryData", + "members": [ + { + "astId": 24562, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "name", + "offset": 0, + "slot": "0", + "type": "t_bytes32" + }, + { + "astId": 24564, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "version", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_struct(RoleData)1722_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 1719, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_struct(AddressSet)5815_storage" + }, + { + "astId": 1721, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "adminRole", + "offset": 0, + "slot": "2", + "type": "t_bytes32" + } + ], + "numberOfBytes": "96" + }, + "t_struct(Set)5550_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 5545, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 5549, + "contract": "contracts/registries/MasterRegistry.sol:MasterRegistry", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} diff --git a/deployments/base_testnet/MetaSwapDepositV1.json b/deployments/base_testnet/MetaSwapDepositV1.json new file mode 100644 index 00000000..690737fc --- /dev/null +++ b/deployments/base_testnet/MetaSwapDepositV1.json @@ -0,0 +1,712 @@ +{ + "address": "0x5dD186f8809147F96D3ffC4508F3C82694E58c9c", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "minToMint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "baseSwap", + "outputs": [ + { + "internalType": "contract ISwapV2", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "baseTokens", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "calculateRemoveLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + } + ], + "name": "calculateRemoveLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + } + ], + "name": "calculateSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "calculateTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISwapV2", + "name": "_baseSwap", + "type": "address" + }, + { + "internalType": "contract IMetaSwapV1", + "name": "_metaSwap", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "_metaLPToken", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "metaLPToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "metaSwap", + "outputs": [ + { + "internalType": "contract IMetaSwapV1", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "metaTokens", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxBurnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityImbalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "minAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minDy", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xa1edfbfb69aee5519a1a3c892441c46f776a4e936585602bc6f0c28d5ad184c1", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0x5dD186f8809147F96D3ffC4508F3C82694E58c9c", + "transactionIndex": 1, + "gasUsed": "3134667", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x433032d767a043c2c86d0efb91a67d4714490c41c45373d6534efaf54426c74c", + "transactionHash": "0xa1edfbfb69aee5519a1a3c892441c46f776a4e936585602bc6f0c28d5ad184c1", + "logs": [], + "blockNumber": 2717068, + "cumulativeGasUsed": "3134667", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"minToMint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseSwap\",\"outputs\":[{\"internalType\":\"contract ISwapV2\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"baseTokens\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateRemoveLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"}],\"name\":\"calculateRemoveLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"}],\"name\":\"calculateSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"calculateTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ISwapV2\",\"name\":\"_baseSwap\",\"type\":\"address\"},{\"internalType\":\"contract IMetaSwapV1\",\"name\":\"_metaSwap\",\"type\":\"address\"},{\"internalType\":\"contract IERC20\",\"name\":\"_metaLPToken\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"metaLPToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"metaSwap\",\"outputs\":[{\"internalType\":\"contract IMetaSwapV1\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"metaTokens\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"minAmounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"maxBurnAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityImbalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"minAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDy\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tokens\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"deadline\":\"latest timestamp to accept this transaction\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation\"},\"returns\":{\"_0\":\"amount of LP token user minted and received\"}},\"calculateRemoveLiquidity(uint256)\":{\"params\":{\"amount\":\"the amount of LP tokens that would be burned on withdrawal\"},\"returns\":{\"_0\":\"array of token balances that the user will receive\"}},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"params\":{\"tokenAmount\":\"the amount of LP token to burn\",\"tokenIndex\":\"index of which token will be withdrawn\"},\"returns\":{\"_0\":\"availableTokenAmount calculated amount of underlying token available to withdraw\"}},\"calculateSwap(uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of tokens the user will receive\"}},\"calculateTokenAmount(uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\"},\"returns\":{\"_0\":\"token amount the user will receive\"}},\"getToken(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"address of the token at given index\"}},\"initialize(address,address,address)\":{\"params\":{\"_baseSwap\":\"the address of the base Swap contract\",\"_metaLPToken\":\"the address of the MetaSwap LP token contract\",\"_metaSwap\":\"the address of the MetaSwap contract\"}},\"removeLiquidity(uint256,uint256[],uint256)\":{\"details\":\"Liquidity can always be removed, even when the pool is paused.\",\"params\":{\"amount\":\"the amount of LP tokens to burn\",\"deadline\":\"latest timestamp to accept this transaction\",\"minAmounts\":\"the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation\"},\"returns\":{\"_0\":\"amounts of tokens user received\"}},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"deadline\":\"latest timestamp to accept this transaction\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\"},\"returns\":{\"_0\":\"amount of LP tokens burned\"}},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"tokenAmount\":\"the amount of the token you want to receive\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount of chosen token user received\"}},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"dx\":\"the amount of tokens the user wants to swap from\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"tokenIndexFrom\":\"the token the user wants to swap from\",\"tokenIndexTo\":\"the token the user wants to swap to\"}}},\"title\":\"MetaSwapDeposit\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"notice\":\"Add liquidity to the pool with the given amounts of tokens\"},\"calculateRemoveLiquidity(uint256)\":{\"notice\":\"A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens\"},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"notice\":\"Calculate the amount of underlying token available to withdraw when withdrawing via only single token\"},\"calculateSwap(uint8,uint8,uint256)\":{\"notice\":\"Calculate amount of tokens you receive on swap\"},\"calculateTokenAmount(uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running. When withdrawing from the base pool in imbalanced fashion, the recommended slippage setting is 0.2% or higher.\"},\"getToken(uint8)\":{\"notice\":\"Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range. This is a flattened representation of the pooled tokens.\"},\"initialize(address,address,address)\":{\"notice\":\"Sets the address for the base Swap contract, MetaSwap contract, and the MetaSwap LP token contract.\"},\"removeLiquidity(uint256,uint256[],uint256)\":{\"notice\":\"Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"notice\":\"Swap two underlying tokens using the meta pool and the base pool\"}},\"notice\":\"This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be deployed before this contract can be initialized successfully. For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD. MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act as a Swap containing [sUSD, DAI, USDC, USDT] tokens.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/meta/MetaSwapDepositV1.sol\":\"MetaSwapDepositV1\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/security/ReentrancyGuardUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuardUpgradeable is Initializable {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n function __ReentrancyGuard_init() internal onlyInitializing {\\n __ReentrancyGuard_init_unchained();\\n }\\n\\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\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\":\"0x8cc03c5ac17e8a7396e487cda41fc1f1dfdb91db7d528e6da84bee3b6dd7e167\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/IMetaSwapV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./ISwapV2.sol\\\";\\n\\ninterface IMetaSwapV1 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function isGuarded() external view returns (bool);\\n\\n function metaSwapStorage()\\n external\\n view\\n returns (\\n address baseSwap,\\n uint256 baseVirtualPrice,\\n uint256 baseCacheLastUpdated\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateSwapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function initializeMetaSwap(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress,\\n ISwapV2 baseSwap\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function swapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xff2475aa3a8950d48535ac9af8f4d6ffe49ebfea1928852424149e711e158e0c\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"},\"contracts/meta/MetaSwapDepositV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/security/ReentrancyGuardUpgradeable.sol\\\";\\nimport \\\"../LPTokenV2.sol\\\";\\nimport \\\"../interfaces/ISwapV2.sol\\\";\\nimport \\\"../interfaces/IMetaSwapV1.sol\\\";\\n\\n/**\\n * @title MetaSwapDeposit\\n * @notice This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be\\n * deployed before this contract can be initialized successfully.\\n *\\n * For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT].\\n * Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either\\n * the LP token or the underlying tokens and sUSD.\\n *\\n * MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users\\n * to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act\\n * as a Swap containing [sUSD, DAI, USDC, USDT] tokens.\\n */\\ncontract MetaSwapDepositV1 is Initializable, ReentrancyGuardUpgradeable {\\n using SafeERC20 for IERC20;\\n\\n ISwapV2 public baseSwap;\\n IMetaSwapV1 public metaSwap;\\n IERC20[] public baseTokens;\\n IERC20[] public metaTokens;\\n IERC20[] public tokens;\\n IERC20 public metaLPToken;\\n\\n uint256 constant MAX_UINT256 = 2**256 - 1;\\n\\n struct RemoveLiquidityImbalanceInfo {\\n ISwapV2 baseSwap;\\n IMetaSwapV1 metaSwap;\\n IERC20 metaLPToken;\\n uint8 baseLPTokenIndex;\\n bool withdrawFromBase;\\n uint256 leftoverMetaLPTokenAmount;\\n }\\n\\n /**\\n * @notice Sets the address for the base Swap contract, MetaSwap contract, and the\\n * MetaSwap LP token contract.\\n * @param _baseSwap the address of the base Swap contract\\n * @param _metaSwap the address of the MetaSwap contract\\n * @param _metaLPToken the address of the MetaSwap LP token contract\\n */\\n function initialize(\\n ISwapV2 _baseSwap,\\n IMetaSwapV1 _metaSwap,\\n IERC20 _metaLPToken\\n ) external initializer {\\n __ReentrancyGuard_init();\\n // Check and approve base level tokens to be deposited to the base Swap contract\\n {\\n uint8 i;\\n for (; i < 32; i++) {\\n try _baseSwap.getToken(i) returns (IERC20 token) {\\n baseTokens.push(token);\\n token.safeApprove(address(_baseSwap), MAX_UINT256);\\n token.safeApprove(address(_metaSwap), MAX_UINT256);\\n } catch {\\n break;\\n }\\n }\\n require(i > 1, \\\"baseSwap must have at least 2 tokens\\\");\\n }\\n\\n // Check and approve meta level tokens to be deposited to the MetaSwap contract\\n IERC20 baseLPToken;\\n {\\n uint8 i;\\n for (; i < 32; i++) {\\n try _metaSwap.getToken(i) returns (IERC20 token) {\\n baseLPToken = token;\\n metaTokens.push(token);\\n tokens.push(token);\\n token.safeApprove(address(_metaSwap), MAX_UINT256);\\n } catch {\\n break;\\n }\\n }\\n require(i > 1, \\\"metaSwap must have at least 2 tokens\\\");\\n }\\n\\n // Flatten baseTokens and append it to tokens array\\n tokens[tokens.length - 1] = baseTokens[0];\\n for (uint8 i = 1; i < baseTokens.length; i++) {\\n tokens.push(baseTokens[i]);\\n }\\n\\n // Approve base Swap LP token to be burned by the base Swap contract for withdrawing\\n baseLPToken.safeApprove(address(_baseSwap), MAX_UINT256);\\n // Approve MetaSwap LP token to be burned by the MetaSwap contract for withdrawing\\n _metaLPToken.safeApprove(address(_metaSwap), MAX_UINT256);\\n\\n // Initialize storage variables\\n baseSwap = _baseSwap;\\n metaSwap = _metaSwap;\\n metaLPToken = _metaLPToken;\\n }\\n\\n // Mutative functions\\n\\n /**\\n * @notice Swap two underlying tokens using the meta pool and the base pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n tokens[tokenIndexFrom].safeTransferFrom(msg.sender, address(this), dx);\\n uint256 tokenToAmount = metaSwap.swapUnderlying(\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n minDy,\\n deadline\\n );\\n tokens[tokenIndexTo].safeTransfer(msg.sender, tokenToAmount);\\n return tokenToAmount;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n // Read to memory to save on gas\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\\n\\n require(amounts.length == memBaseTokens.length + baseLPTokenIndex);\\n\\n uint256 baseLPTokenAmount;\\n {\\n // Transfer base tokens from the caller and deposit to the base Swap pool\\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\\n bool shouldDepositBaseTokens;\\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\\n IERC20 token = memBaseTokens[i];\\n uint256 depositAmount = amounts[baseLPTokenIndex + i];\\n if (depositAmount > 0) {\\n token.safeTransferFrom(\\n msg.sender,\\n address(this),\\n depositAmount\\n );\\n baseAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\\n // if there are any base Swap level tokens, flag it for deposits\\n shouldDepositBaseTokens = true;\\n }\\n }\\n if (shouldDepositBaseTokens) {\\n // Deposit any base Swap level tokens and receive baseLPToken\\n baseLPTokenAmount = baseSwap.addLiquidity(\\n baseAmounts,\\n 0,\\n deadline\\n );\\n }\\n }\\n\\n uint256 metaLPTokenAmount;\\n {\\n // Transfer remaining meta level tokens from the caller\\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n IERC20 token = memMetaTokens[i];\\n uint256 depositAmount = amounts[i];\\n if (depositAmount > 0) {\\n token.safeTransferFrom(\\n msg.sender,\\n address(this),\\n depositAmount\\n );\\n metaAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\\n }\\n }\\n // Update the baseLPToken amount that will be deposited\\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\\n\\n // Deposit the meta level tokens and the baseLPToken\\n metaLPTokenAmount = metaSwap.addLiquidity(\\n metaAmounts,\\n minToMint,\\n deadline\\n );\\n }\\n\\n // Transfer the meta lp token to the caller\\n metaLPToken.safeTransfer(msg.sender, metaLPTokenAmount);\\n\\n return metaLPTokenAmount;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amounts of tokens user received\\n */\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external nonReentrant returns (uint256[] memory) {\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256[] memory totalRemovedAmounts;\\n\\n {\\n uint256 numOfAllTokens = memBaseTokens.length +\\n memMetaTokens.length -\\n 1;\\n require(minAmounts.length == numOfAllTokens, \\\"out of range\\\");\\n totalRemovedAmounts = new uint256[](numOfAllTokens);\\n }\\n\\n // Transfer meta lp token from the caller to this\\n metaLPToken.safeTransferFrom(msg.sender, address(this), amount);\\n\\n uint256 baseLPTokenAmount;\\n {\\n // Remove liquidity from the MetaSwap pool\\n uint256[] memory removedAmounts;\\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\\n {\\n uint256[] memory metaMinAmounts = new uint256[](\\n memMetaTokens.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n metaMinAmounts[i] = minAmounts[i];\\n }\\n removedAmounts = metaSwap.removeLiquidity(\\n amount,\\n metaMinAmounts,\\n deadline\\n );\\n }\\n\\n // Send the meta level tokens to the caller\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n totalRemovedAmounts[i] = removedAmounts[i];\\n memMetaTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\\n }\\n baseLPTokenAmount = removedAmounts[baseLPTokenIndex];\\n\\n // Remove liquidity from the base Swap pool\\n {\\n uint256[] memory baseMinAmounts = new uint256[](\\n memBaseTokens.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];\\n }\\n removedAmounts = baseSwap.removeLiquidity(\\n baseLPTokenAmount,\\n baseMinAmounts,\\n deadline\\n );\\n }\\n\\n // Send the base level tokens to the caller\\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\\n totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i];\\n memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\\n }\\n }\\n\\n return totalRemovedAmounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\\n uint8 baseTokensLength = uint8(baseTokens.length);\\n\\n // Transfer metaLPToken from the caller\\n metaLPToken.safeTransferFrom(msg.sender, address(this), tokenAmount);\\n\\n IERC20 token;\\n if (tokenIndex < baseLPTokenIndex) {\\n // When the desired token is meta level token, we can just call `removeLiquidityOneToken` directly\\n metaSwap.removeLiquidityOneToken(\\n tokenAmount,\\n tokenIndex,\\n minAmount,\\n deadline\\n );\\n token = metaTokens[tokenIndex];\\n } else if (tokenIndex < baseLPTokenIndex + baseTokensLength) {\\n // When the desired token is a base level token, we need to first withdraw via baseLPToken, then withdraw\\n // the desired token from the base Swap contract.\\n uint256 removedBaseLPTokenAmount = metaSwap.removeLiquidityOneToken(\\n tokenAmount,\\n baseLPTokenIndex,\\n 0,\\n deadline\\n );\\n\\n baseSwap.removeLiquidityOneToken(\\n removedBaseLPTokenAmount,\\n tokenIndex - baseLPTokenIndex,\\n minAmount,\\n deadline\\n );\\n token = baseTokens[tokenIndex - baseLPTokenIndex];\\n } else {\\n revert(\\\"out of range\\\");\\n }\\n\\n uint256 amountWithdrawn = token.balanceOf(address(this));\\n token.safeTransfer(msg.sender, amountWithdrawn);\\n return amountWithdrawn;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256[] memory metaAmounts = new uint256[](memMetaTokens.length);\\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\\n\\n require(\\n amounts.length == memBaseTokens.length + memMetaTokens.length - 1,\\n \\\"out of range\\\"\\n );\\n\\n RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(\\n baseSwap,\\n metaSwap,\\n metaLPToken,\\n uint8(metaAmounts.length - 1),\\n false,\\n 0\\n );\\n\\n for (uint8 i = 0; i < v.baseLPTokenIndex; i++) {\\n metaAmounts[i] = amounts[i];\\n }\\n\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n baseAmounts[i] = amounts[v.baseLPTokenIndex + i];\\n if (baseAmounts[i] > 0) {\\n v.withdrawFromBase = true;\\n }\\n }\\n\\n // Calculate how much base LP token we need to get the desired amount of underlying tokens\\n if (v.withdrawFromBase) {\\n metaAmounts[v.baseLPTokenIndex] =\\n (v.baseSwap.calculateTokenAmount(baseAmounts, false) * 10005) /\\n 10000;\\n }\\n\\n // Transfer MetaSwap LP token from the caller to this contract\\n v.metaLPToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n maxBurnAmount\\n );\\n\\n // Withdraw the paired meta level tokens and the base LP token from the MetaSwap pool\\n uint256 burnedMetaLPTokenAmount = v.metaSwap.removeLiquidityImbalance(\\n metaAmounts,\\n maxBurnAmount,\\n deadline\\n );\\n v.leftoverMetaLPTokenAmount = maxBurnAmount - burnedMetaLPTokenAmount;\\n\\n // If underlying tokens are desired, withdraw them from the base Swap pool\\n if (v.withdrawFromBase) {\\n v.baseSwap.removeLiquidityImbalance(\\n baseAmounts,\\n metaAmounts[v.baseLPTokenIndex],\\n deadline\\n );\\n\\n // Base Swap may require LESS base LP token than the amount we have\\n // In that case, deposit it to the MetaSwap pool.\\n uint256[] memory leftovers = new uint256[](metaAmounts.length);\\n IERC20 baseLPToken = memMetaTokens[v.baseLPTokenIndex];\\n uint256 leftoverBaseLPTokenAmount = baseLPToken.balanceOf(\\n address(this)\\n );\\n if (leftoverBaseLPTokenAmount > 0) {\\n leftovers[v.baseLPTokenIndex] = leftoverBaseLPTokenAmount;\\n v.leftoverMetaLPTokenAmount =\\n v.leftoverMetaLPTokenAmount +\\n v.metaSwap.addLiquidity(leftovers, 0, deadline);\\n }\\n }\\n\\n // Transfer all withdrawn tokens to the caller\\n for (uint8 i = 0; i < amounts.length; i++) {\\n IERC20 token;\\n if (i < v.baseLPTokenIndex) {\\n token = memMetaTokens[i];\\n } else {\\n token = memBaseTokens[i - v.baseLPTokenIndex];\\n }\\n if (amounts[i] > 0) {\\n token.safeTransfer(msg.sender, amounts[i]);\\n }\\n }\\n\\n // If there were any extra meta lp token, transfer them back to the caller as well\\n if (v.leftoverMetaLPTokenAmount > 0) {\\n v.metaLPToken.safeTransfer(msg.sender, v.leftoverMetaLPTokenAmount);\\n }\\n\\n return maxBurnAmount - v.leftoverMetaLPTokenAmount;\\n }\\n\\n // VIEW FUNCTIONS\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running. When withdrawing from the base pool in imbalanced\\n * fashion, the recommended slippage setting is 0.2% or higher.\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256)\\n {\\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\\n uint256[] memory baseAmounts = new uint256[](baseTokens.length);\\n uint256 baseLPTokenIndex = metaAmounts.length - 1;\\n\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n metaAmounts[i] = amounts[i];\\n }\\n\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n baseAmounts[i] = amounts[baseLPTokenIndex + i];\\n }\\n\\n uint256 baseLPTokenAmount = baseSwap.calculateTokenAmount(\\n baseAmounts,\\n deposit\\n );\\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\\n\\n return metaSwap.calculateTokenAmount(metaAmounts, deposit);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of LP tokens\\n * @param amount the amount of LP tokens that would be burned on withdrawal\\n * @return array of token balances that the user will receive\\n */\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n uint256[] memory metaAmounts = metaSwap.calculateRemoveLiquidity(\\n amount\\n );\\n uint8 baseLPTokenIndex = uint8(metaAmounts.length - 1);\\n uint256[] memory baseAmounts = baseSwap.calculateRemoveLiquidity(\\n metaAmounts[baseLPTokenIndex]\\n );\\n\\n uint256[] memory totalAmounts = new uint256[](\\n baseLPTokenIndex + baseAmounts.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n totalAmounts[i] = metaAmounts[i];\\n }\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n totalAmounts[baseLPTokenIndex + i] = baseAmounts[i];\\n }\\n\\n return totalAmounts;\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\\n\\n if (tokenIndex < baseLPTokenIndex) {\\n return\\n metaSwap.calculateRemoveLiquidityOneToken(\\n tokenAmount,\\n tokenIndex\\n );\\n } else {\\n uint256 baseLPTokenAmount = metaSwap\\n .calculateRemoveLiquidityOneToken(\\n tokenAmount,\\n baseLPTokenIndex\\n );\\n return\\n baseSwap.calculateRemoveLiquidityOneToken(\\n baseLPTokenAmount,\\n tokenIndex - baseLPTokenIndex\\n );\\n }\\n }\\n\\n /**\\n * @notice Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range.\\n * This is a flattened representation of the pooled tokens.\\n * @param index the index of the token\\n * @return address of the token at given index\\n */\\n function getToken(uint8 index) external view returns (IERC20) {\\n require(index < tokens.length, \\\"index out of range\\\");\\n return tokens[index];\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256) {\\n return\\n metaSwap.calculateSwapUnderlying(tokenIndexFrom, tokenIndexTo, dx);\\n }\\n}\\n\",\"keccak256\":\"0x9b0d9ddd45892ef1af392b0ea1a8e0112422df19e52459f495216d864bb193af\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506137fe806100206000396000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c806391695586116100b2578063cb2ef5fe11610081578063e6ab280611610066578063e6ab280614610268578063f2fad2b61461027b578063fd0bd0991461028e57600080fd5b8063cb2ef5fe14610242578063d26504721461025557600080fd5b806391695586146101f45780639750a8ee14610207578063a95b089f1461021a578063c0c53b8b1461022d57600080fd5b80634d49e87d116100ee5780634d49e87d146101a85780634f64b2be146101bb57806382b86600146101ce57806384cdd9bc146101e157600080fd5b806331cd52b014610120578063328123a214610149578063342a87a1146101745780633e3a156014610195575b600080fd5b61013361012e36600461319f565b6102a1565b604051610140919061322d565b60405180910390f35b61015c610157366004613240565b6108a6565b6040516001600160a01b039091168152602001610140565b61018761018236600461326f565b6108d0565b604051908152602001610140565b6101876101a336600461329b565b610ac5565b6101876101b63660046132d6565b610ec6565b61015c6101c9366004613240565b61146e565b61015c6101dc366004613327565b61147e565b6101876101ef3660046132d6565b611506565b610187610202366004613342565b611d91565b60335461015c906001600160a01b031681565b61018761022836600461338f565b611f15565b61024061023b3660046133e3565b611fb7565b005b60345461015c906001600160a01b031681565b60385461015c906001600160a01b031681565b61018761027636600461343c565b6126d6565b610133610289366004613240565b612988565b61015c61029c366004613240565b612bf3565b60606002600154036102fa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260015560358054604080516020808402820181019092528281526000939092909183018282801561035657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610338575b50505050509050600060368054806020026020016040519081016040528092919081815260200182805480156103b557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610397575b50505050509050606060006001835185516103d091906134b7565b6103da91906134ca565b905086811461042b5760405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b8067ffffffffffffffff811115610444576104446134dd565b60405190808252806020026020018201604052801561046d578160200160208202803683370190505b5060385490925061048a91506001600160a01b031633308b612c03565b6000606060006001855161049e91906134ca565b90506000855167ffffffffffffffff8111156104bc576104bc6134dd565b6040519080825280602002602001820160405280156104e5578160200160208202803683370190505b50905060005b828160ff161015610544578b8b8260ff1681811061050b5761050b61350c565b90506020020135828260ff16815181106105275761052761350c565b60209081029190910101528061053c8161353b565b9150506104eb565b506034546040517f31cd52b00000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906331cd52b090610592908f9085908e9060040161355a565b6000604051808303816000875af11580156105b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105d99190810190613583565b92505060005b818160ff16101561069057828160ff16815181106105ff576105ff61350c565b6020026020010151858260ff168151811061061c5761061c61350c565b60200260200101818152505061067e33848360ff16815181106106415761064161350c565b6020026020010151888460ff168151811061065e5761065e61350c565b60200260200101516001600160a01b0316612cb49092919063ffffffff16565b806106888161353b565b9150506105df565b508181815181106106a3576106a361350c565b602002602001015192506000865167ffffffffffffffff8111156106c9576106c96134dd565b6040519080825280602002602001820160405280156106f2578160200160208202803683370190505b50905060005b828160ff16101561075a578b8b61071260ff8416866134b7565b8181106107215761072161350c565b90506020020135828260ff168151811061073d5761073d61350c565b6020908102919091010152806107528161353b565b9150506106f8565b506033546040517f31cd52b00000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906331cd52b0906107a890879085908e9060040161355a565b6000604051808303816000875af11580156107c7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107ef9190810190613583565b92505060005b86518160ff16101561089257828160ff16815181106108165761081661350c565b6020026020010151858260ff168461082e91906134b7565b8151811061083e5761083e61350c565b60200260200101818152505061088033848360ff16815181106108635761086361350c565b6020026020010151898460ff168151811061065e5761065e61350c565b8061088a8161353b565b9150506107f5565b505060018055509098975050505050505050565b603581815481106108b657600080fd5b6000918252602090912001546001600160a01b0316905081565b60365460009081906108e4906001906134ca565b90508060ff168360ff16101561098b576034546040517f342a87a10000000000000000000000000000000000000000000000000000000081526004810186905260ff851660248201526001600160a01b039091169063342a87a190604401602060405180830381865afa15801561095f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109839190613635565b915050610abf565b6034546040517f342a87a10000000000000000000000000000000000000000000000000000000081526004810186905260ff831660248201526000916001600160a01b03169063342a87a190604401602060405180830381865afa1580156109f7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1b9190613635565b6033549091506001600160a01b031663342a87a182610a3a858861364e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604401602060405180830381865afa158015610a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aba9190613635565b925050505b92915050565b6000600260015403610b195760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b60026001908155603654600091610b2f916134ca565b60355460385491925090610b4e906001600160a01b031633308a612c03565b60008260ff168760ff161015610c30576034546040517f3e3a1560000000000000000000000000000000000000000000000000000000008152600481018a905260ff8916602482015260448101889052606481018790526001600160a01b0390911690633e3a1560906084016020604051808303816000875af1158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd9190613635565b5060368760ff1681548110610c1457610c1461350c565b6000918252602090912001546001600160a01b03169050610e1c565b610c3a8284613667565b60ff168760ff161015610dd4576034546040517f3e3a1560000000000000000000000000000000000000000000000000000000008152600481018a905260ff8516602482015260006044820181905260648201889052916001600160a01b031690633e3a1560906084016020604051808303816000875af1158015610cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce79190613635565b6033549091506001600160a01b0316633e3a156082610d06878c61364e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604481018a9052606481018990526084016020604051808303816000875af1158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d969190613635565b506035610da3858a61364e565b60ff1681548110610db657610db661350c565b6000918252602090912001546001600160a01b03169150610e1c9050565b60405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea09190613635565b9050610eb66001600160a01b0383163383612cb4565b6001805598975050505050505050565b6000600260015403610f1a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b6002600155603580546040805160208084028201810190925282815260009390929091830182828015610f7657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610f58575b5050505050905060006036805480602002602001604051908101604052809291908181526020018280548015610fd557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fb7575b50505050509050600060018251610fec91906134ca565b9050808351610ffb91906134b7565b871461100657600080fd5b600080845167ffffffffffffffff811115611023576110236134dd565b60405190808252806020026020018201604052801561104c578160200160208202803683370190505b5090506000805b86518160ff161015611185576000878260ff16815181106110765761107661350c565b6020026020010151905060008d8d8460ff168961109391906134b7565b8181106110a2576110a261350c565b9050602002013590506000811115611170576110c96001600160a01b038316333084612c03565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114a9190613635565b858460ff168151811061115f5761115f61350c565b602002602001018181525050600193505b5050808061117d9061353b565b915050611053565b508015611220576033546040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634d49e87d906111da9085906000908d90600401613680565b6020604051808303816000875af11580156111f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121d9190613635565b92505b5050603654600090819067ffffffffffffffff811115611242576112426134dd565b60405190808252806020026020018201604052801561126b578160200160208202803683370190505b50905060005b848160ff161015611393576000868260ff16815181106112935761129361350c565b6020026020010151905060008d8d8460ff168181106112b4576112b461350c565b905060200201359050600081111561137e576112db6001600160a01b038316333084612c03565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135c9190613635565b848460ff16815181106113715761137161350c565b6020026020010181815250505b5050808061138b9061353b565b915050611271565b50828185815181106113a7576113a761350c565b60209081029190910101526034546040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634d49e87d906113ff9084908d908d90600401613680565b6020604051808303816000875af115801561141e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114429190613635565b60385490925061145d91506001600160a01b03163383612cb4565b600180559998505050505050505050565b603781815481106108b657600080fd5b60375460009060ff8316106114d55760405162461bcd60e51b815260206004820152601260248201527f696e646578206f7574206f662072616e6765000000000000000000000000000060448201526064016102f1565b60378260ff16815481106114eb576114eb61350c565b6000918252602090912001546001600160a01b031692915050565b600060026001540361155a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b60026001556035805460408051602080840282018101909252828152600093909290918301828280156115b657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611598575b505050505090506000603680548060200260200160405190810160405280929190818152602001828054801561161557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116115f7575b505050505090506000815167ffffffffffffffff811115611638576116386134dd565b604051908082528060200260200182016040528015611661578160200160208202803683370190505b5090506000835167ffffffffffffffff811115611680576116806134dd565b6040519080825280602002602001820160405280156116a9578160200160208202803683370190505b5090506001835185516116bc91906134b7565b6116c691906134ca565b88146117145760405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b6040805160c0810182526033546001600160a01b039081168252603454811660208301526038541691810191909152825160009190606082019061175a906001906134ca565b60ff1681526020016000151581526020016000815250905060005b816060015160ff168160ff1610156117d5578a8a8260ff1681811061179c5761179c61350c565b90506020020135848260ff16815181106117b8576117b861350c565b6020908102919091010152806117cd8161353b565b915050611775565b5060005b82518160ff161015611870578a8a8284606001516117f79190613667565b60ff168181106118095761180961350c565b90506020020135838260ff16815181106118255761182561350c565b6020026020010181815250506000838260ff16815181106118485761184861350c565b6020026020010151111561185e57600160808301525b806118688161353b565b9150506117d9565b508060800151156119455780516040517fe6ab2806000000000000000000000000000000000000000000000000000000008152612710916001600160a01b03169063e6ab2806906118c89086906000906004016136a5565b602060405180830381865afa1580156118e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119099190613635565b611915906127156136c9565b61191f91906136e0565b83826060015160ff16815181106119385761193861350c565b6020026020010181815250505b604081015161195f906001600160a01b031633308b612c03565b60208101516040517f84cdd9bc0000000000000000000000000000000000000000000000000000000081526000916001600160a01b0316906384cdd9bc906119af9087908d908d90600401613680565b6020604051808303816000875af11580156119ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f29190613635565b90506119fe818a6134ca565b60a0830152608082015115611c595781600001516001600160a01b03166384cdd9bc8486856060015160ff1681518110611a3a57611a3a61350c565b60200260200101518b6040518463ffffffff1660e01b8152600401611a6193929190613680565b6020604051808303816000875af1158015611a80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa49190613635565b506000845167ffffffffffffffff811115611ac157611ac16134dd565b604051908082528060200260200182016040528015611aea578160200160208202803683370190505b509050600086846060015160ff1681518110611b0857611b0861350c565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9a9190613635565b90508015611c55578083866060015160ff1681518110611bbc57611bbc61350c565b60200260200101818152505084602001516001600160a01b0316634d49e87d8460008e6040518463ffffffff1660e01b8152600401611bfd93929190613680565b6020604051808303816000875af1158015611c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c409190613635565b8560a00151611c4f91906134b7565b60a08601525b5050505b60005b60ff81168b1115611d3e576000836060015160ff168260ff161015611c9f57868260ff1681518110611c9057611c9061350c565b60200260200101519050611cce565b87846060015183611cb0919061364e565b60ff1681518110611cc357611cc361350c565b602002602001015190505b60008d8d8460ff16818110611ce557611ce561350c565b905060200201351115611d2b57611d2b338e8e8560ff16818110611d0b57611d0b61350c565b90506020020135836001600160a01b0316612cb49092919063ffffffff16565b5080611d368161353b565b915050611c5c565b5060a082015115611d6f57611d6f338360a0015184604001516001600160a01b0316612cb49092919063ffffffff16565b60a0820151611d7e908a6134ca565b600180559b9a5050505050505050505050565b6000600260015403611de55760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b6002600181905550611e2633308660378a60ff1681548110611e0957611e0961350c565b6000918252602090912001546001600160a01b0316929190612c03565b6034546040517f78e0fae800000000000000000000000000000000000000000000000000000000815260ff8089166004830152871660248201526044810186905260648101859052608481018490526000916001600160a01b0316906378e0fae89060a4016020604051808303816000875af1158015611eaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ece9190613635565b9050611f07338260378960ff1681548110611eeb57611eeb61350c565b6000918252602090912001546001600160a01b03169190612cb4565b600180559695505050505050565b6034546040517f75d8e3e400000000000000000000000000000000000000000000000000000000815260ff808616600483015284166024820152604481018390526000916001600160a01b0316906375d8e3e490606401602060405180830381865afa158015611f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fad9190613635565b90505b9392505050565b600054610100900460ff1615808015611fd75750600054600160ff909116105b80611ff15750303b158015611ff1575060005460ff166001145b6120635760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016102f1565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156120c157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6120c9612d02565b60005b60208160ff161015612231576040517f82b8660000000000000000000000000000000000000000000000000000000000815260ff821660048201526001600160a01b038616906382b8660090602401602060405180830381865afa925050508015612154575060408051601f3d908101601f191682019092526121519181019061371b565b60015b1561223157603580546001810182556000919091527fcfa4bec1d3298408bb5afcfcd9c430549c5b31f8aa5c5848151c0a55f473c34d0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556121ea90877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b61221e6001600160a01b038216867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50806122298161353b565b9150506120cc565b60018160ff16116122a95760405162461bcd60e51b8152602060048201526024808201527f6261736553776170206d7573742068617665206174206c65617374203220746f60448201527f6b656e730000000000000000000000000000000000000000000000000000000060648201526084016102f1565b506000805b60208160ff16101561241b576040517f82b8660000000000000000000000000000000000000000000000000000000000815260ff821660048201526001600160a01b038616906382b8660090602401602060405180830381865afa925050508015612336575060408051601f3d908101601f191682019092526123339181019061371b565b60015b1561241b576036805460018181019092557f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b80180546001600160a01b0384167fffffffffffffffffffffffff000000000000000000000000000000000000000091821681179092556037805493840181556000527f42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae90920180549092168117909155909250829061240890877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50806124138161353b565b9150506122ae565b60018160ff16116124935760405162461bcd60e51b8152602060048201526024808201527f6d65746153776170206d7573742068617665206174206c65617374203220746f60448201527f6b656e730000000000000000000000000000000000000000000000000000000060648201526084016102f1565b5060356000815481106124a8576124a861350c565b600091825260209091200154603780546001600160a01b03909216916124d0906001906134ca565b815481106124e0576124e061350c565b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905560015b60355460ff821610156125ae57603760358260ff16815481106125495761254961350c565b60009182526020808320909101548354600181018555938352912090910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055806125a68161353b565b915050612524565b506125e36001600160a01b038216867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b6126176001600160a01b038416857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50603380546001600160a01b038087167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560348054868416908316179055603880549285169290911691909117905580156126d057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b603654600090819067ffffffffffffffff8111156126f6576126f66134dd565b60405190808252806020026020018201604052801561271f578160200160208202803683370190505b5060355490915060009067ffffffffffffffff811115612741576127416134dd565b60405190808252806020026020018201604052801561276a578160200160208202803683370190505b50905060006001835161277d91906134ca565b905060005b818160ff1610156127db5787878260ff168181106127a2576127a261350c565b90506020020135848260ff16815181106127be576127be61350c565b6020908102919091010152806127d38161353b565b915050612782565b5060005b82518160ff1610156128425787876127fa60ff8416856134b7565b8181106128095761280961350c565b90506020020135838260ff16815181106128255761282561350c565b60209081029190910101528061283a8161353b565b9150506127df565b506033546040517fe6ab28060000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063e6ab28069061288f9086908a906004016136a5565b602060405180830381865afa1580156128ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d09190613635565b9050808483815181106128e5576128e561350c565b60209081029190910101526034546040517fe6ab28060000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063e6ab28069061293b9087908a906004016136a5565b602060405180830381865afa158015612958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297c9190613635565b98975050505050505050565b6034546040517ff2fad2b6000000000000000000000000000000000000000000000000000000008152600481018390526060916000916001600160a01b039091169063f2fad2b690602401600060405180830381865afa1580156129f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a189190810190613583565b9050600060018251612a2a91906134ca565b60335483519192506000916001600160a01b039091169063f2fad2b690859060ff8616908110612a5c57612a5c61350c565b60200260200101516040518263ffffffff1660e01b8152600401612a8291815260200190565b600060405180830381865afa158015612a9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ac79190810190613583565b9050600081518360ff16612adb91906134b7565b67ffffffffffffffff811115612af357612af36134dd565b604051908082528060200260200182016040528015612b1c578160200160208202803683370190505b50905060005b8360ff168160ff161015612b7f57848160ff1681518110612b4557612b4561350c565b6020026020010151828260ff1681518110612b6257612b6261350c565b602090810291909101015280612b778161353b565b915050612b22565b5060005b82518160ff161015612be957828160ff1681518110612ba457612ba461350c565b6020026020010151828286612bb99190613667565b60ff1681518110612bcc57612bcc61350c565b602090810291909101015280612be18161353b565b915050612b83565b5095945050505050565b603681815481106108b657600080fd5b6040516001600160a01b03808516602483015283166044820152606481018290526126d09085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612ed7565b6040516001600160a01b038316602482015260448101829052612cfd9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612c50565b505050565b600054610100900460ff16612d7f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016102f1565b612d87612fbc565b565b801580612e1c57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e1a9190613635565b155b612e8e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016102f1565b6040516001600160a01b038316602482015260448101829052612cfd9084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401612c50565b6000612f2c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661303f9092919063ffffffff16565b805190915015612cfd5780806020019051810190612f4a9190613738565b612cfd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016102f1565b600054610100900460ff166130395760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016102f1565b60018055565b6060611fad8484600085856001600160a01b0385163b6130a15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102f1565b600080866001600160a01b031685876040516130bd9190613779565b60006040518083038185875af1925050503d80600081146130fa576040519150601f19603f3d011682016040523d82523d6000602084013e6130ff565b606091505b509150915061310f82828661311a565b979650505050505050565b60608315613129575081611fb0565b8251156131395782518084602001fd5b8160405162461bcd60e51b81526004016102f19190613795565b60008083601f84011261316557600080fd5b50813567ffffffffffffffff81111561317d57600080fd5b6020830191508360208260051b850101111561319857600080fd5b9250929050565b600080600080606085870312156131b557600080fd5b84359350602085013567ffffffffffffffff8111156131d357600080fd5b6131df87828801613153565b9598909750949560400135949350505050565b600081518084526020808501945080840160005b8381101561322257815187529582019590820190600101613206565b509495945050505050565b602081526000611fb060208301846131f2565b60006020828403121561325257600080fd5b5035919050565b803560ff8116811461326a57600080fd5b919050565b6000806040838503121561328257600080fd5b8235915061329260208401613259565b90509250929050565b600080600080608085870312156132b157600080fd5b843593506132c160208601613259565b93969395505050506040820135916060013590565b600080600080606085870312156132ec57600080fd5b843567ffffffffffffffff81111561330357600080fd5b61330f87828801613153565b90989097506020870135966040013595509350505050565b60006020828403121561333957600080fd5b611fb082613259565b600080600080600060a0868803121561335a57600080fd5b61336386613259565b945061337160208701613259565b94979496505050506040830135926060810135926080909101359150565b6000806000606084860312156133a457600080fd5b6133ad84613259565b92506133bb60208501613259565b9150604084013590509250925092565b6001600160a01b03811681146133e057600080fd5b50565b6000806000606084860312156133f857600080fd5b8335613403816133cb565b92506020840135613413816133cb565b91506040840135613423816133cb565b809150509250925092565b80151581146133e057600080fd5b60008060006040848603121561345157600080fd5b833567ffffffffffffffff81111561346857600080fd5b61347486828701613153565b90945092505060208401356134238161342e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610abf57610abf613488565b81810381811115610abf57610abf613488565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060ff821660ff810361355157613551613488565b60010192915050565b83815260606020820152600061357360608301856131f2565b9050826040830152949350505050565b6000602080838503121561359657600080fd5b825167ffffffffffffffff808211156135ae57600080fd5b818501915085601f8301126135c257600080fd5b8151818111156135d4576135d46134dd565b8060051b604051601f19603f830116810181811085821117156135f9576135f96134dd565b60405291825284820192508381018501918883111561361757600080fd5b938501935b8285101561297c5784518452938501939285019261361c565b60006020828403121561364757600080fd5b5051919050565b60ff8281168282160390811115610abf57610abf613488565b60ff8181168382160190811115610abf57610abf613488565b60608152600061369360608301866131f2565b60208301949094525060400152919050565b6040815260006136b860408301856131f2565b905082151560208301529392505050565b8082028115828204841417610abf57610abf613488565b600082613716577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60006020828403121561372d57600080fd5b8151611fb0816133cb565b60006020828403121561374a57600080fd5b8151611fb08161342e565b60005b83811015613770578181015183820152602001613758565b50506000910152565b6000825161378b818460208701613755565b9190910192915050565b60208152600082518060208401526137b4816040850160208701613755565b601f01601f1916919091016040019291505056fea2646970667358221220c3ae2178735d9262c9364d64b9eafa791c70cceff0647e8e35c0f5dbcc40adba64736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061011b5760003560e01c806391695586116100b2578063cb2ef5fe11610081578063e6ab280611610066578063e6ab280614610268578063f2fad2b61461027b578063fd0bd0991461028e57600080fd5b8063cb2ef5fe14610242578063d26504721461025557600080fd5b806391695586146101f45780639750a8ee14610207578063a95b089f1461021a578063c0c53b8b1461022d57600080fd5b80634d49e87d116100ee5780634d49e87d146101a85780634f64b2be146101bb57806382b86600146101ce57806384cdd9bc146101e157600080fd5b806331cd52b014610120578063328123a214610149578063342a87a1146101745780633e3a156014610195575b600080fd5b61013361012e36600461319f565b6102a1565b604051610140919061322d565b60405180910390f35b61015c610157366004613240565b6108a6565b6040516001600160a01b039091168152602001610140565b61018761018236600461326f565b6108d0565b604051908152602001610140565b6101876101a336600461329b565b610ac5565b6101876101b63660046132d6565b610ec6565b61015c6101c9366004613240565b61146e565b61015c6101dc366004613327565b61147e565b6101876101ef3660046132d6565b611506565b610187610202366004613342565b611d91565b60335461015c906001600160a01b031681565b61018761022836600461338f565b611f15565b61024061023b3660046133e3565b611fb7565b005b60345461015c906001600160a01b031681565b60385461015c906001600160a01b031681565b61018761027636600461343c565b6126d6565b610133610289366004613240565b612988565b61015c61029c366004613240565b612bf3565b60606002600154036102fa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260015560358054604080516020808402820181019092528281526000939092909183018282801561035657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610338575b50505050509050600060368054806020026020016040519081016040528092919081815260200182805480156103b557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610397575b50505050509050606060006001835185516103d091906134b7565b6103da91906134ca565b905086811461042b5760405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b8067ffffffffffffffff811115610444576104446134dd565b60405190808252806020026020018201604052801561046d578160200160208202803683370190505b5060385490925061048a91506001600160a01b031633308b612c03565b6000606060006001855161049e91906134ca565b90506000855167ffffffffffffffff8111156104bc576104bc6134dd565b6040519080825280602002602001820160405280156104e5578160200160208202803683370190505b50905060005b828160ff161015610544578b8b8260ff1681811061050b5761050b61350c565b90506020020135828260ff16815181106105275761052761350c565b60209081029190910101528061053c8161353b565b9150506104eb565b506034546040517f31cd52b00000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906331cd52b090610592908f9085908e9060040161355a565b6000604051808303816000875af11580156105b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105d99190810190613583565b92505060005b818160ff16101561069057828160ff16815181106105ff576105ff61350c565b6020026020010151858260ff168151811061061c5761061c61350c565b60200260200101818152505061067e33848360ff16815181106106415761064161350c565b6020026020010151888460ff168151811061065e5761065e61350c565b60200260200101516001600160a01b0316612cb49092919063ffffffff16565b806106888161353b565b9150506105df565b508181815181106106a3576106a361350c565b602002602001015192506000865167ffffffffffffffff8111156106c9576106c96134dd565b6040519080825280602002602001820160405280156106f2578160200160208202803683370190505b50905060005b828160ff16101561075a578b8b61071260ff8416866134b7565b8181106107215761072161350c565b90506020020135828260ff168151811061073d5761073d61350c565b6020908102919091010152806107528161353b565b9150506106f8565b506033546040517f31cd52b00000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906331cd52b0906107a890879085908e9060040161355a565b6000604051808303816000875af11580156107c7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526107ef9190810190613583565b92505060005b86518160ff16101561089257828160ff16815181106108165761081661350c565b6020026020010151858260ff168461082e91906134b7565b8151811061083e5761083e61350c565b60200260200101818152505061088033848360ff16815181106108635761086361350c565b6020026020010151898460ff168151811061065e5761065e61350c565b8061088a8161353b565b9150506107f5565b505060018055509098975050505050505050565b603581815481106108b657600080fd5b6000918252602090912001546001600160a01b0316905081565b60365460009081906108e4906001906134ca565b90508060ff168360ff16101561098b576034546040517f342a87a10000000000000000000000000000000000000000000000000000000081526004810186905260ff851660248201526001600160a01b039091169063342a87a190604401602060405180830381865afa15801561095f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109839190613635565b915050610abf565b6034546040517f342a87a10000000000000000000000000000000000000000000000000000000081526004810186905260ff831660248201526000916001600160a01b03169063342a87a190604401602060405180830381865afa1580156109f7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1b9190613635565b6033549091506001600160a01b031663342a87a182610a3a858861364e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604401602060405180830381865afa158015610a96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aba9190613635565b925050505b92915050565b6000600260015403610b195760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b60026001908155603654600091610b2f916134ca565b60355460385491925090610b4e906001600160a01b031633308a612c03565b60008260ff168760ff161015610c30576034546040517f3e3a1560000000000000000000000000000000000000000000000000000000008152600481018a905260ff8916602482015260448101889052606481018790526001600160a01b0390911690633e3a1560906084016020604051808303816000875af1158015610bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfd9190613635565b5060368760ff1681548110610c1457610c1461350c565b6000918252602090912001546001600160a01b03169050610e1c565b610c3a8284613667565b60ff168760ff161015610dd4576034546040517f3e3a1560000000000000000000000000000000000000000000000000000000008152600481018a905260ff8516602482015260006044820181905260648201889052916001600160a01b031690633e3a1560906084016020604051808303816000875af1158015610cc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce79190613635565b6033549091506001600160a01b0316633e3a156082610d06878c61364e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604481018a9052606481018990526084016020604051808303816000875af1158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d969190613635565b506035610da3858a61364e565b60ff1681548110610db657610db661350c565b6000918252602090912001546001600160a01b03169150610e1c9050565b60405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea09190613635565b9050610eb66001600160a01b0383163383612cb4565b6001805598975050505050505050565b6000600260015403610f1a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b6002600155603580546040805160208084028201810190925282815260009390929091830182828015610f7657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610f58575b5050505050905060006036805480602002602001604051908101604052809291908181526020018280548015610fd557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fb7575b50505050509050600060018251610fec91906134ca565b9050808351610ffb91906134b7565b871461100657600080fd5b600080845167ffffffffffffffff811115611023576110236134dd565b60405190808252806020026020018201604052801561104c578160200160208202803683370190505b5090506000805b86518160ff161015611185576000878260ff16815181106110765761107661350c565b6020026020010151905060008d8d8460ff168961109391906134b7565b8181106110a2576110a261350c565b9050602002013590506000811115611170576110c96001600160a01b038316333084612c03565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114a9190613635565b858460ff168151811061115f5761115f61350c565b602002602001018181525050600193505b5050808061117d9061353b565b915050611053565b508015611220576033546040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634d49e87d906111da9085906000908d90600401613680565b6020604051808303816000875af11580156111f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121d9190613635565b92505b5050603654600090819067ffffffffffffffff811115611242576112426134dd565b60405190808252806020026020018201604052801561126b578160200160208202803683370190505b50905060005b848160ff161015611393576000868260ff16815181106112935761129361350c565b6020026020010151905060008d8d8460ff168181106112b4576112b461350c565b905060200201359050600081111561137e576112db6001600160a01b038316333084612c03565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135c9190613635565b848460ff16815181106113715761137161350c565b6020026020010181815250505b5050808061138b9061353b565b915050611271565b50828185815181106113a7576113a761350c565b60209081029190910101526034546040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634d49e87d906113ff9084908d908d90600401613680565b6020604051808303816000875af115801561141e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114429190613635565b60385490925061145d91506001600160a01b03163383612cb4565b600180559998505050505050505050565b603781815481106108b657600080fd5b60375460009060ff8316106114d55760405162461bcd60e51b815260206004820152601260248201527f696e646578206f7574206f662072616e6765000000000000000000000000000060448201526064016102f1565b60378260ff16815481106114eb576114eb61350c565b6000918252602090912001546001600160a01b031692915050565b600060026001540361155a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b60026001556035805460408051602080840282018101909252828152600093909290918301828280156115b657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611598575b505050505090506000603680548060200260200160405190810160405280929190818152602001828054801561161557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116115f7575b505050505090506000815167ffffffffffffffff811115611638576116386134dd565b604051908082528060200260200182016040528015611661578160200160208202803683370190505b5090506000835167ffffffffffffffff811115611680576116806134dd565b6040519080825280602002602001820160405280156116a9578160200160208202803683370190505b5090506001835185516116bc91906134b7565b6116c691906134ca565b88146117145760405162461bcd60e51b815260206004820152600c60248201527f6f7574206f662072616e6765000000000000000000000000000000000000000060448201526064016102f1565b6040805160c0810182526033546001600160a01b039081168252603454811660208301526038541691810191909152825160009190606082019061175a906001906134ca565b60ff1681526020016000151581526020016000815250905060005b816060015160ff168160ff1610156117d5578a8a8260ff1681811061179c5761179c61350c565b90506020020135848260ff16815181106117b8576117b861350c565b6020908102919091010152806117cd8161353b565b915050611775565b5060005b82518160ff161015611870578a8a8284606001516117f79190613667565b60ff168181106118095761180961350c565b90506020020135838260ff16815181106118255761182561350c565b6020026020010181815250506000838260ff16815181106118485761184861350c565b6020026020010151111561185e57600160808301525b806118688161353b565b9150506117d9565b508060800151156119455780516040517fe6ab2806000000000000000000000000000000000000000000000000000000008152612710916001600160a01b03169063e6ab2806906118c89086906000906004016136a5565b602060405180830381865afa1580156118e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119099190613635565b611915906127156136c9565b61191f91906136e0565b83826060015160ff16815181106119385761193861350c565b6020026020010181815250505b604081015161195f906001600160a01b031633308b612c03565b60208101516040517f84cdd9bc0000000000000000000000000000000000000000000000000000000081526000916001600160a01b0316906384cdd9bc906119af9087908d908d90600401613680565b6020604051808303816000875af11580156119ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f29190613635565b90506119fe818a6134ca565b60a0830152608082015115611c595781600001516001600160a01b03166384cdd9bc8486856060015160ff1681518110611a3a57611a3a61350c565b60200260200101518b6040518463ffffffff1660e01b8152600401611a6193929190613680565b6020604051808303816000875af1158015611a80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa49190613635565b506000845167ffffffffffffffff811115611ac157611ac16134dd565b604051908082528060200260200182016040528015611aea578160200160208202803683370190505b509050600086846060015160ff1681518110611b0857611b0861350c565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611b76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9a9190613635565b90508015611c55578083866060015160ff1681518110611bbc57611bbc61350c565b60200260200101818152505084602001516001600160a01b0316634d49e87d8460008e6040518463ffffffff1660e01b8152600401611bfd93929190613680565b6020604051808303816000875af1158015611c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c409190613635565b8560a00151611c4f91906134b7565b60a08601525b5050505b60005b60ff81168b1115611d3e576000836060015160ff168260ff161015611c9f57868260ff1681518110611c9057611c9061350c565b60200260200101519050611cce565b87846060015183611cb0919061364e565b60ff1681518110611cc357611cc361350c565b602002602001015190505b60008d8d8460ff16818110611ce557611ce561350c565b905060200201351115611d2b57611d2b338e8e8560ff16818110611d0b57611d0b61350c565b90506020020135836001600160a01b0316612cb49092919063ffffffff16565b5080611d368161353b565b915050611c5c565b5060a082015115611d6f57611d6f338360a0015184604001516001600160a01b0316612cb49092919063ffffffff16565b60a0820151611d7e908a6134ca565b600180559b9a5050505050505050505050565b6000600260015403611de55760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102f1565b6002600181905550611e2633308660378a60ff1681548110611e0957611e0961350c565b6000918252602090912001546001600160a01b0316929190612c03565b6034546040517f78e0fae800000000000000000000000000000000000000000000000000000000815260ff8089166004830152871660248201526044810186905260648101859052608481018490526000916001600160a01b0316906378e0fae89060a4016020604051808303816000875af1158015611eaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ece9190613635565b9050611f07338260378960ff1681548110611eeb57611eeb61350c565b6000918252602090912001546001600160a01b03169190612cb4565b600180559695505050505050565b6034546040517f75d8e3e400000000000000000000000000000000000000000000000000000000815260ff808616600483015284166024820152604481018390526000916001600160a01b0316906375d8e3e490606401602060405180830381865afa158015611f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fad9190613635565b90505b9392505050565b600054610100900460ff1615808015611fd75750600054600160ff909116105b80611ff15750303b158015611ff1575060005460ff166001145b6120635760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016102f1565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156120c157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6120c9612d02565b60005b60208160ff161015612231576040517f82b8660000000000000000000000000000000000000000000000000000000000815260ff821660048201526001600160a01b038616906382b8660090602401602060405180830381865afa925050508015612154575060408051601f3d908101601f191682019092526121519181019061371b565b60015b1561223157603580546001810182556000919091527fcfa4bec1d3298408bb5afcfcd9c430549c5b31f8aa5c5848151c0a55f473c34d0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556121ea90877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b61221e6001600160a01b038216867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50806122298161353b565b9150506120cc565b60018160ff16116122a95760405162461bcd60e51b8152602060048201526024808201527f6261736553776170206d7573742068617665206174206c65617374203220746f60448201527f6b656e730000000000000000000000000000000000000000000000000000000060648201526084016102f1565b506000805b60208160ff16101561241b576040517f82b8660000000000000000000000000000000000000000000000000000000000815260ff821660048201526001600160a01b038616906382b8660090602401602060405180830381865afa925050508015612336575060408051601f3d908101601f191682019092526123339181019061371b565b60015b1561241b576036805460018181019092557f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b80180546001600160a01b0384167fffffffffffffffffffffffff000000000000000000000000000000000000000091821681179092556037805493840181556000527f42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae90920180549092168117909155909250829061240890877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50806124138161353b565b9150506122ae565b60018160ff16116124935760405162461bcd60e51b8152602060048201526024808201527f6d65746153776170206d7573742068617665206174206c65617374203220746f60448201527f6b656e730000000000000000000000000000000000000000000000000000000060648201526084016102f1565b5060356000815481106124a8576124a861350c565b600091825260209091200154603780546001600160a01b03909216916124d0906001906134ca565b815481106124e0576124e061350c565b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905560015b60355460ff821610156125ae57603760358260ff16815481106125495761254961350c565b60009182526020808320909101548354600181018555938352912090910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055806125a68161353b565b915050612524565b506125e36001600160a01b038216867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b6126176001600160a01b038416857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612d89565b50603380546001600160a01b038087167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560348054868416908316179055603880549285169290911691909117905580156126d057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b603654600090819067ffffffffffffffff8111156126f6576126f66134dd565b60405190808252806020026020018201604052801561271f578160200160208202803683370190505b5060355490915060009067ffffffffffffffff811115612741576127416134dd565b60405190808252806020026020018201604052801561276a578160200160208202803683370190505b50905060006001835161277d91906134ca565b905060005b818160ff1610156127db5787878260ff168181106127a2576127a261350c565b90506020020135848260ff16815181106127be576127be61350c565b6020908102919091010152806127d38161353b565b915050612782565b5060005b82518160ff1610156128425787876127fa60ff8416856134b7565b8181106128095761280961350c565b90506020020135838260ff16815181106128255761282561350c565b60209081029190910101528061283a8161353b565b9150506127df565b506033546040517fe6ab28060000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063e6ab28069061288f9086908a906004016136a5565b602060405180830381865afa1580156128ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d09190613635565b9050808483815181106128e5576128e561350c565b60209081029190910101526034546040517fe6ab28060000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063e6ab28069061293b9087908a906004016136a5565b602060405180830381865afa158015612958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297c9190613635565b98975050505050505050565b6034546040517ff2fad2b6000000000000000000000000000000000000000000000000000000008152600481018390526060916000916001600160a01b039091169063f2fad2b690602401600060405180830381865afa1580156129f0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a189190810190613583565b9050600060018251612a2a91906134ca565b60335483519192506000916001600160a01b039091169063f2fad2b690859060ff8616908110612a5c57612a5c61350c565b60200260200101516040518263ffffffff1660e01b8152600401612a8291815260200190565b600060405180830381865afa158015612a9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ac79190810190613583565b9050600081518360ff16612adb91906134b7565b67ffffffffffffffff811115612af357612af36134dd565b604051908082528060200260200182016040528015612b1c578160200160208202803683370190505b50905060005b8360ff168160ff161015612b7f57848160ff1681518110612b4557612b4561350c565b6020026020010151828260ff1681518110612b6257612b6261350c565b602090810291909101015280612b778161353b565b915050612b22565b5060005b82518160ff161015612be957828160ff1681518110612ba457612ba461350c565b6020026020010151828286612bb99190613667565b60ff1681518110612bcc57612bcc61350c565b602090810291909101015280612be18161353b565b915050612b83565b5095945050505050565b603681815481106108b657600080fd5b6040516001600160a01b03808516602483015283166044820152606481018290526126d09085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612ed7565b6040516001600160a01b038316602482015260448101829052612cfd9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612c50565b505050565b600054610100900460ff16612d7f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016102f1565b612d87612fbc565b565b801580612e1c57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e1a9190613635565b155b612e8e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016102f1565b6040516001600160a01b038316602482015260448101829052612cfd9084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401612c50565b6000612f2c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661303f9092919063ffffffff16565b805190915015612cfd5780806020019051810190612f4a9190613738565b612cfd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016102f1565b600054610100900460ff166130395760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016102f1565b60018055565b6060611fad8484600085856001600160a01b0385163b6130a15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102f1565b600080866001600160a01b031685876040516130bd9190613779565b60006040518083038185875af1925050503d80600081146130fa576040519150601f19603f3d011682016040523d82523d6000602084013e6130ff565b606091505b509150915061310f82828661311a565b979650505050505050565b60608315613129575081611fb0565b8251156131395782518084602001fd5b8160405162461bcd60e51b81526004016102f19190613795565b60008083601f84011261316557600080fd5b50813567ffffffffffffffff81111561317d57600080fd5b6020830191508360208260051b850101111561319857600080fd5b9250929050565b600080600080606085870312156131b557600080fd5b84359350602085013567ffffffffffffffff8111156131d357600080fd5b6131df87828801613153565b9598909750949560400135949350505050565b600081518084526020808501945080840160005b8381101561322257815187529582019590820190600101613206565b509495945050505050565b602081526000611fb060208301846131f2565b60006020828403121561325257600080fd5b5035919050565b803560ff8116811461326a57600080fd5b919050565b6000806040838503121561328257600080fd5b8235915061329260208401613259565b90509250929050565b600080600080608085870312156132b157600080fd5b843593506132c160208601613259565b93969395505050506040820135916060013590565b600080600080606085870312156132ec57600080fd5b843567ffffffffffffffff81111561330357600080fd5b61330f87828801613153565b90989097506020870135966040013595509350505050565b60006020828403121561333957600080fd5b611fb082613259565b600080600080600060a0868803121561335a57600080fd5b61336386613259565b945061337160208701613259565b94979496505050506040830135926060810135926080909101359150565b6000806000606084860312156133a457600080fd5b6133ad84613259565b92506133bb60208501613259565b9150604084013590509250925092565b6001600160a01b03811681146133e057600080fd5b50565b6000806000606084860312156133f857600080fd5b8335613403816133cb565b92506020840135613413816133cb565b91506040840135613423816133cb565b809150509250925092565b80151581146133e057600080fd5b60008060006040848603121561345157600080fd5b833567ffffffffffffffff81111561346857600080fd5b61347486828701613153565b90945092505060208401356134238161342e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610abf57610abf613488565b81810381811115610abf57610abf613488565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060ff821660ff810361355157613551613488565b60010192915050565b83815260606020820152600061357360608301856131f2565b9050826040830152949350505050565b6000602080838503121561359657600080fd5b825167ffffffffffffffff808211156135ae57600080fd5b818501915085601f8301126135c257600080fd5b8151818111156135d4576135d46134dd565b8060051b604051601f19603f830116810181811085821117156135f9576135f96134dd565b60405291825284820192508381018501918883111561361757600080fd5b938501935b8285101561297c5784518452938501939285019261361c565b60006020828403121561364757600080fd5b5051919050565b60ff8281168282160390811115610abf57610abf613488565b60ff8181168382160190811115610abf57610abf613488565b60608152600061369360608301866131f2565b60208301949094525060400152919050565b6040815260006136b860408301856131f2565b905082151560208301529392505050565b8082028115828204841417610abf57610abf613488565b600082613716577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60006020828403121561372d57600080fd5b8151611fb0816133cb565b60006020828403121561374a57600080fd5b8151611fb08161342e565b60005b83811015613770578181015183820152602001613758565b50506000910152565b6000825161378b818460208701613755565b9190910192915050565b60208152600082518060208401526137b4816040850160208701613755565b601f01601f1916919091016040019291505056fea2646970667358221220c3ae2178735d9262c9364d64b9eafa791c70cceff0647e8e35c0f5dbcc40adba64736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "deadline": "latest timestamp to accept this transaction", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation" + }, + "returns": { + "_0": "amount of LP token user minted and received" + } + }, + "calculateRemoveLiquidity(uint256)": { + "params": { + "amount": "the amount of LP tokens that would be burned on withdrawal" + }, + "returns": { + "_0": "array of token balances that the user will receive" + } + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "params": { + "tokenAmount": "the amount of LP token to burn", + "tokenIndex": "index of which token will be withdrawn" + }, + "returns": { + "_0": "availableTokenAmount calculated amount of underlying token available to withdraw" + } + }, + "calculateSwap(uint8,uint8,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of tokens the user will receive" + } + }, + "calculateTokenAmount(uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal" + }, + "returns": { + "_0": "token amount the user will receive" + } + }, + "getToken(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "address of the token at given index" + } + }, + "initialize(address,address,address)": { + "params": { + "_baseSwap": "the address of the base Swap contract", + "_metaLPToken": "the address of the MetaSwap LP token contract", + "_metaSwap": "the address of the MetaSwap contract" + } + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "details": "Liquidity can always be removed, even when the pool is paused.", + "params": { + "amount": "the amount of LP tokens to burn", + "deadline": "latest timestamp to accept this transaction", + "minAmounts": "the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation" + }, + "returns": { + "_0": "amounts of tokens user received" + } + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "deadline": "latest timestamp to accept this transaction", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation." + }, + "returns": { + "_0": "amount of LP tokens burned" + } + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "minAmount": "the minimum amount to withdraw, otherwise revert", + "tokenAmount": "the amount of the token you want to receive", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount of chosen token user received" + } + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "dx": "the amount of tokens the user wants to swap from", + "minDy": "the min amount the user would like to receive, or revert.", + "tokenIndexFrom": "the token the user wants to swap from", + "tokenIndexTo": "the token the user wants to swap to" + } + } + }, + "title": "MetaSwapDeposit", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "notice": "Add liquidity to the pool with the given amounts of tokens" + }, + "calculateRemoveLiquidity(uint256)": { + "notice": "A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens" + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "notice": "Calculate the amount of underlying token available to withdraw when withdrawing via only single token" + }, + "calculateSwap(uint8,uint8,uint256)": { + "notice": "Calculate amount of tokens you receive on swap" + }, + "calculateTokenAmount(uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running. When withdrawing from the base pool in imbalanced fashion, the recommended slippage setting is 0.2% or higher." + }, + "getToken(uint8)": { + "notice": "Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range. This is a flattened representation of the pooled tokens." + }, + "initialize(address,address,address)": { + "notice": "Sets the address for the base Swap contract, MetaSwap contract, and the MetaSwap LP token contract." + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "notice": "Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "notice": "Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "notice": "Swap two underlying tokens using the meta pool and the base pool" + } + }, + "notice": "This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be deployed before this contract can be initialized successfully. For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD. MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act as a Swap containing [sUSD, DAI, USDC, USDT] tokens.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1654, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 1657, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1939, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "_status", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 1983, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "__gap", + "offset": 0, + "slot": "2", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 7988, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "baseSwap", + "offset": 0, + "slot": "51", + "type": "t_contract(ISwapV2)7968" + }, + { + "astId": 7991, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "metaSwap", + "offset": 0, + "slot": "52", + "type": "t_contract(IMetaSwapV1)7763" + }, + { + "astId": 7995, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "baseTokens", + "offset": 0, + "slot": "53", + "type": "t_array(t_contract(IERC20)856)dyn_storage" + }, + { + "astId": 7999, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "metaTokens", + "offset": 0, + "slot": "54", + "type": "t_array(t_contract(IERC20)856)dyn_storage" + }, + { + "astId": 8003, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "tokens", + "offset": 0, + "slot": "55", + "type": "t_array(t_contract(IERC20)856)dyn_storage" + }, + { + "astId": 8006, + "contract": "contracts/meta/MetaSwapDepositV1.sol:MetaSwapDepositV1", + "label": "metaLPToken", + "offset": 0, + "slot": "56", + "type": "t_contract(IERC20)856" + } + ], + "types": { + "t_array(t_contract(IERC20)856)dyn_storage": { + "base": "t_contract(IERC20)856", + "encoding": "dynamic_array", + "label": "contract IERC20[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)856": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(IMetaSwapV1)7763": { + "encoding": "inplace", + "label": "contract IMetaSwapV1", + "numberOfBytes": "20" + }, + "t_contract(ISwapV2)7968": { + "encoding": "inplace", + "label": "contract ISwapV2", + "numberOfBytes": "20" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/MetaSwapUtilsV1.json b/deployments/base_testnet/MetaSwapUtilsV1.json new file mode 100644 index 00000000..1eac31b9 --- /dev/null +++ b/deployments/base_testnet/MetaSwapUtilsV1.json @@ -0,0 +1,443 @@ +{ + "address": "0xfeEa4D1BacB0519E8f952460A70719944fe56Ee0", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "AddLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "NewSwapFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newWithdrawFee", + "type": "uint256" + } + ], + "name": "NewWithdrawFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidityImbalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "boughtId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + } + ], + "name": "RemoveLiquidityOne", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwapUnderlying", + "type": "event" + }, + { + "inputs": [], + "name": "BASE_CACHE_EXPIRE_TIME", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BASE_VIRTUAL_PRICE_PRECISION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x7ceb8cb300abd693e7f7547b36f80650fa26b5f03871032389b3e465841ceb51", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xfeEa4D1BacB0519E8f952460A70719944fe56Ee0", + "transactionIndex": 1, + "gasUsed": "4492218", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3c0644b6fd386fbcbfa2f19bb3a6583a74ff32ef74428839fef3ccb2bea49338", + "transactionHash": "0x7ceb8cb300abd693e7f7547b36f80650fa26b5f03871032389b3e465841ceb51", + "logs": [], + "blockNumber": 2717058, + "cumulativeGasUsed": "4492218", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"NewSwapFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newWithdrawFee\",\"type\":\"uint256\"}],\"name\":\"NewWithdrawFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityImbalance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"boughtId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityOne\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwap\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwapUnderlying\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BASE_CACHE_EXPIRE_TIME\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"BASE_VIRTUAL_PRICE_PRECISION\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contracts relying on this library must initialize SwapUtils.Swap struct then use this library for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins. Admin functions should be protected within contracts using this library.\",\"kind\":\"dev\",\"methods\":{\"addLiquidity(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"metaSwapStorage\":\"MetaSwap struct to read from and write to\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\",\"self\":\"Swap struct to read from and write to\"},\"returns\":{\"_0\":\"amount of LP token user received\"}},\"calculateSwap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"metaSwapStorage\":\"MetaSwap struct from the same contract\",\"self\":\"Swap struct to read from\",\"tokenIndexFrom\":\"the token to sell\",\"tokenIndexTo\":\"the token to buy\"},\"returns\":{\"dy\":\"the number of tokens the user will get\"}},\"calculateSwapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"metaSwapStorage\":\"MetaSwap struct from the same contract\",\"self\":\"Swap struct to read from\",\"tokenIndexFrom\":\"the token to sell\",\"tokenIndexTo\":\"the token to buy\"},\"returns\":{\"_0\":\"dy the number of tokens the user will get\"}},\"calculateTokenAmount(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\",\"metaSwapStorage\":\"MetaSwap struct to read from\",\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"if deposit was true, total amount of lp token that will be minted and if deposit was false, total amount of lp token that will be burned\"}},\"calculateWithdrawOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8)\":{\"params\":{\"metaSwapStorage\":\"MetaSwap struct to read from\",\"self\":\"Swap struct to read from\",\"tokenAmount\":\"the amount to withdraw in the pool's precision\",\"tokenIndex\":\"which token will be withdrawn\"},\"returns\":{\"dy\":\"the amount of token user will receive\"}},\"getVirtualPrice(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage)\":{\"params\":{\"metaSwapStorage\":\"MetaSwap struct to read from\",\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION\"}},\"removeLiquidityImbalance(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\",\"metaSwapStorage\":\"MetaSwap struct to read from and write to\",\"self\":\"Swap struct to read from and write to\"},\"returns\":{\"_0\":\"actual amount of LP tokens burned in the withdrawal\"}},\"removeLiquidityOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8,uint256)\":{\"params\":{\"metaSwapStorage\":\"MetaSwap struct to read from and write to\",\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"self\":\"Swap struct to read from and write to\",\"tokenAmount\":\"the amount of the lp tokens to burn\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount chosen token that user received\"}},\"swap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell\",\"metaSwapStorage\":\"MetaSwap struct to read from and write to\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"self\":\"Swap struct to read from and write to\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of token user received on swap\"}},\"swapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)\":{\"details\":\"Since this calls multiple external functions during the execution, it is recommended to protect any function that depends on this with reentrancy guards.\",\"params\":{\"dx\":\"the amount of tokens the user wants to sell\",\"metaSwapStorage\":\"MetaSwap struct to read from and write to\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"self\":\"Swap struct to read from and write to\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of token user received on swap\"}}},\"title\":\"MetaSwapUtils library\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)\":{\"notice\":\"Add liquidity to the pool\"},\"calculateSwap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)\":{\"notice\":\"Externally calculates a swap between two tokens. The SwapUtils.Swap storage and MetaSwap storage should be from the same MetaSwap contract.\"},\"calculateSwapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)\":{\"notice\":\"Calculates the expected return amount from swapping between the pooled tokens and the underlying tokens of the base Swap pool.\"},\"calculateTokenAmount(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running\"},\"calculateWithdrawOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8)\":{\"notice\":\"Calculate how much the user would receive when withdrawing via single token\"},\"getVirtualPrice(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage)\":{\"notice\":\"Get the virtual price, to help calculate profit\"},\"removeLiquidityImbalance(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances.\"},\"removeLiquidityOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token.\"},\"swap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)\":{\"notice\":\"swap two tokens in the pool\"},\"swapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)\":{\"notice\":\"Swaps with the underlying tokens of the base Swap pool. For this function, the token indices are flattened out so that underlying tokens are represented in the indices.\"}},\"notice\":\"A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities. MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens. As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/meta/MetaSwapUtilsV1.sol\":\"MetaSwapUtilsV1\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/AmplificationUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./SwapUtilsV2.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtilsV2 {\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return (_getAPrecise(self) / A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtilsV2.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return a0 + (((a1 - a0) * (block.timestamp - t0)) / (t1 - t0));\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return a0 - (((a0 - a1) * (block.timestamp - t0)) / (t1 - t0));\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtilsV2.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= (self.initialATime + (1 days)),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= (block.timestamp + MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_ * A_PRECISION;\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n (futureAPrecise * MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= (initialAPrecise * MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtilsV2.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0xb52146d1964ede58f1cb59bff4fa507d30eeae9b11c213941bcbda047fe9e4fb\",\"license\":\"MIT\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/MathUtilsV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtilsV1 {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x39534ffe365ac4796eebdd5d505ed58c425bc65861ccf118eb0f6cd26c654f0b\",\"license\":\"MIT\"},\"contracts/SwapUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtilsV2.sol\\\";\\nimport \\\"./LPTokenV2.sol\\\";\\nimport \\\"./MathUtilsV1.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtilsV2 {\\n using SafeERC20 for IERC20;\\n using MathUtilsV1 for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPTokenV2 lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPTokenV2 lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount * (fee) / (FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtilsV2._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = ((currentY - newY) /\\n self.tokenPrecisionMultipliers[tokenIndex]) - dy;\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] =\\n xpi -\\n (((\\n (i == tokenIndex)\\n ? ((xpi * v.d1) / v.d0) - v.newY\\n : xpi - ((xpi * v.d1) / v.d0)\\n ) * v.feePerToken) / FEE_DENOMINATOR);\\n }\\n\\n uint256 dy = xpReduced[tokenIndex] -\\n (getYD(v.preciseA, tokenIndex, xpReduced, v.d1));\\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a * (numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s + xp[i];\\n c = (c * d) / (xp[i] * (numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = ((y * y) + c) / ((y * 2) + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s + xp[i];\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a * numTokens;\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = (dP * d) / (xp[j] * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d =\\n ((((nA * s) / AmplificationUtilsV2.A_PRECISION) +\\n (dP * numTokens)) * d) /\\n ((((nA - AmplificationUtilsV2.A_PRECISION) * d) /\\n AmplificationUtilsV2.A_PRECISION) + ((numTokens + 1) * dP));\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i] * precisionMultipliers[i];\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPTokenV2 lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return (d * (10**uint256(POOL_PRECISION_DECIMALS))) / supply;\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens * preciseA;\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s + _x;\\n c = (c * d) / (_x * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = (y * y + c) / (y * 2 + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx * multipliers[tokenIndexFrom] + xp[tokenIndexFrom];\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo] - y - 1;\\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\\n dy = (dy - dyFee) / multipliers[tokenIndexTo];\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = (balances[i] * amount) / totalSupply;\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i] + amounts[i];\\n } else {\\n if (amounts[i] > balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances[i] = balances[i] - amounts[i];\\n }\\n }\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return (((d1 - d0) * totalSupply) / d0);\\n } else {\\n return (((d0 - d1) * totalSupply) / d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)) -\\n self.balances[index];\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return ((swapFee * numTokens) / ((numTokens - 1) * 4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)) - beforeBalance;\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = (((dyFee * self.adminFee) / FEE_DENOMINATOR) /\\n self.tokenPrecisionMultipliers[tokenIndexTo]);\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom] + dx;\\n self.balances[tokenIndexTo] = balances[tokenIndexTo] - dy - dyAdminFee;\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] =\\n pooledTokens[i].balanceOf(address(this)) -\\n beforeBalance;\\n }\\n\\n newBalances[i] = v.balances[i] + amounts[i];\\n }\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n fees[i] =\\n (feePerToken * idealBalance.difference(newBalances[i])) /\\n FEE_DENOMINATOR;\\n self.balances[i] =\\n newBalances[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n newBalances[i] = newBalances[i] - fees[i];\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply + toMint\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i] - amounts[i];\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply - amount);\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] =\\n self.balances[tokenIndex] -\\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n if (amounts[i] > v.balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = v.balances[i] - amounts[i];\\n }\\n }\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\\n self.balances[i] =\\n balances1[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n balances1[i] = balances1[i] - fees[i];\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount + 1;\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply - tokenAmount\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)) - self.balances[i];\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0xb8d3f47b58b85bddeeb59cc13049f3f7fee2b29ee373fe5427d1f7c8814a1b8b\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"},\"contracts/meta/MetaSwapUtilsV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../LPTokenV2.sol\\\";\\nimport \\\"../interfaces/ISwapV2.sol\\\";\\nimport \\\"../MathUtilsV1.sol\\\";\\nimport \\\"../SwapUtilsV2.sol\\\";\\n\\n/**\\n * @title MetaSwapUtils library\\n * @notice A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities.\\n *\\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created\\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\\n *\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary MetaSwapUtilsV1 {\\n using SafeERC20 for IERC20;\\n using MathUtilsV1 for uint256;\\n using AmplificationUtilsV2 for SwapUtilsV2.Swap;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event TokenSwapUnderlying(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n event NewWithdrawFee(uint256 newWithdrawFee);\\n\\n struct MetaSwap {\\n // Meta-Swap related parameters\\n ISwapV2 baseSwap;\\n uint256 baseVirtualPrice;\\n uint256 baseCacheLastUpdated;\\n IERC20[] baseTokens;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n uint256 xpi;\\n }\\n\\n // Struct storing variables used in calculation in removeLiquidityImbalance function\\n // to avoid stack too deep error\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n LPTokenV2 lpToken;\\n uint256 totalSupply;\\n uint256 preciseA;\\n uint256 baseVirtualPrice;\\n uint256[] tokenPrecisionMultipliers;\\n uint256[] newBalances;\\n }\\n\\n struct SwapUnderlyingInfo {\\n uint256 x;\\n uint256 dx;\\n uint256 dy;\\n uint256[] tokenPrecisionMultipliers;\\n uint256[] oldBalances;\\n IERC20[] baseTokens;\\n IERC20 tokenFrom;\\n uint8 metaIndexFrom;\\n IERC20 tokenTo;\\n uint8 metaIndexTo;\\n uint256 baseVirtualPrice;\\n }\\n\\n struct CalculateSwapUnderlyingInfo {\\n uint256 baseVirtualPrice;\\n ISwapV2 baseSwap;\\n uint8 baseLPTokenIndex;\\n uint8 baseTokensLength;\\n uint8 metaIndexTo;\\n uint256 x;\\n uint256 dy;\\n }\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Cache expire time for the stored value of base Swap's virtual price\\n uint256 public constant BASE_CACHE_EXPIRE_TIME = 10 minutes;\\n uint256 public constant BASE_VIRTUAL_PRICE_PRECISION = 10**18;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n /**\\n * @notice Return the stored value of base Swap's virtual price. If\\n * value was updated past BASE_CACHE_EXPIRE_TIME, then read it directly\\n * from the base Swap contract.\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @return base Swap's virtual price\\n */\\n function _getBaseVirtualPrice(MetaSwap storage metaSwapStorage)\\n internal\\n view\\n returns (uint256)\\n {\\n if (\\n block.timestamp >\\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\\n ) {\\n return metaSwapStorage.baseSwap.getVirtualPrice();\\n }\\n return metaSwapStorage.baseVirtualPrice;\\n }\\n\\n function _getBaseSwapFee(ISwapV2 baseSwap)\\n internal\\n view\\n returns (uint256 swapFee)\\n {\\n (, , , , swapFee, , ) = baseSwap.swapStorage();\\n }\\n\\n /**\\n * @notice Calculate how much the user would receive when withdrawing via single token\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @return dy the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n _getBaseVirtualPrice(metaSwapStorage),\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateWithdrawOneToken(\\n SwapUtilsV2.Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 baseVirtualPrice,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 dySwapFee;\\n\\n {\\n uint256 currentY;\\n uint256 newY;\\n\\n // Calculate how much to withdraw\\n (dy, newY, currentY) = _calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n baseVirtualPrice,\\n totalSupply\\n );\\n\\n // Calculate the associated swap fee\\n dySwapFee =\\n ((currentY - newY) /\\n self.tokenPrecisionMultipliers[tokenIndex]) -\\n dy;\\n }\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @param baseVirtualPrice the virtual price of the base swap's LP token\\n * @return the dy excluding swap fee, the new y after withdrawing one token, and current y\\n */\\n function _calculateWithdrawOneTokenDY(\\n SwapUtilsV2.Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 baseVirtualPrice,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self, baseVirtualPrice);\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(\\n 0,\\n 0,\\n 0,\\n 0,\\n self._getAPrecise(),\\n 0\\n );\\n v.d0 = SwapUtilsV2.getD(xp, v.preciseA);\\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = SwapUtilsV2.getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = SwapUtilsV2._feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n v.xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] =\\n v.xpi -\\n (((\\n (i == tokenIndex)\\n ? (v.xpi * v.d1) / v.d0 - v.newY\\n : v.xpi - ((v.xpi * v.d1) / v.d0)\\n ) * v.feePerToken) / FEE_DENOMINATOR);\\n }\\n\\n uint256 dy = xpReduced[tokenIndex] -\\n SwapUtilsV2.getYD(v.preciseA, tokenIndex, xpReduced, v.d1);\\n\\n if (tokenIndex == xp.length - 1) {\\n dy = (dy * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\\n v.newY = (v.newY * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\\n xp[tokenIndex] =\\n (xp[tokenIndex] * BASE_VIRTUAL_PRICE_PRECISION) /\\n baseVirtualPrice;\\n }\\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances. The last element will also get scaled up by\\n * the given baseVirtualPrice.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @param baseVirtualPrice the base virtual price to scale the balance of the\\n * base Swap's LP token.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers,\\n uint256 baseVirtualPrice\\n ) internal pure returns (uint256[] memory) {\\n uint256[] memory xp = SwapUtilsV2._xp(balances, precisionMultipliers);\\n uint256 baseLPTokenIndex = balances.length - 1;\\n xp[baseLPTokenIndex] =\\n (xp[baseLPTokenIndex] * baseVirtualPrice) /\\n BASE_VIRTUAL_PRICE_PRECISION;\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(SwapUtilsV2.Swap storage self, uint256 baseVirtualPrice)\\n internal\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _xp(\\n self.balances,\\n self.tokenPrecisionMultipliers,\\n baseVirtualPrice\\n );\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @return the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION\\n */\\n function getVirtualPrice(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage\\n ) external view returns (uint256) {\\n uint256 d = SwapUtilsV2.getD(\\n _xp(\\n self.balances,\\n self.tokenPrecisionMultipliers,\\n _getBaseVirtualPrice(metaSwapStorage)\\n ),\\n self._getAPrecise()\\n );\\n uint256 supply = self.lpToken.totalSupply();\\n if (supply != 0) {\\n return (d * BASE_VIRTUAL_PRICE_PRECISION) / supply;\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens. The SwapUtils.Swap storage and\\n * MetaSwap storage should be from the same MetaSwap contract.\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct from the same contract\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n _getBaseVirtualPrice(metaSwapStorage)\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param baseVirtualPrice the virtual price of the base LP token\\n * @return dy the number of tokens the user will get and dyFee the associated fee\\n */\\n function _calculateSwap(\\n SwapUtilsV2.Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 baseVirtualPrice\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory xp = _xp(self, baseVirtualPrice);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 baseLPTokenIndex = xp.length - 1;\\n\\n uint256 x = dx * self.tokenPrecisionMultipliers[tokenIndexFrom];\\n if (tokenIndexFrom == baseLPTokenIndex) {\\n // When swapping from a base Swap token, scale up dx by its virtual price\\n x = (x * baseVirtualPrice) / BASE_VIRTUAL_PRICE_PRECISION;\\n }\\n x = x + xp[tokenIndexFrom];\\n\\n uint256 y = SwapUtilsV2.getY(\\n self._getAPrecise(),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo] - y - 1;\\n\\n if (tokenIndexTo == baseLPTokenIndex) {\\n // When swapping to a base Swap token, scale down dy by its virtual price\\n dy = (dy * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\\n }\\n\\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\\n dy = dy - dyFee;\\n\\n dy = dy / self.tokenPrecisionMultipliers[tokenIndexTo];\\n }\\n\\n /**\\n * @notice Calculates the expected return amount from swapping between\\n * the pooled tokens and the underlying tokens of the base Swap pool.\\n *\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct from the same contract\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwapUnderlying(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256) {\\n CalculateSwapUnderlyingInfo memory v = CalculateSwapUnderlyingInfo(\\n _getBaseVirtualPrice(metaSwapStorage),\\n metaSwapStorage.baseSwap,\\n 0,\\n uint8(metaSwapStorage.baseTokens.length),\\n 0,\\n 0,\\n 0\\n );\\n\\n uint256[] memory xp = _xp(self, v.baseVirtualPrice);\\n v.baseLPTokenIndex = uint8(xp.length - 1);\\n {\\n uint8 maxRange = v.baseLPTokenIndex + v.baseTokensLength;\\n require(\\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\\n \\\"Token index out of range\\\"\\n );\\n }\\n\\n if (tokenIndexFrom < v.baseLPTokenIndex) {\\n // tokenFrom is from this pool\\n v.x =\\n xp[tokenIndexFrom] +\\n (dx * self.tokenPrecisionMultipliers[tokenIndexFrom]);\\n } else {\\n // tokenFrom is from the base pool\\n tokenIndexFrom = tokenIndexFrom - v.baseLPTokenIndex;\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n uint256[] memory baseInputs = new uint256[](v.baseTokensLength);\\n baseInputs[tokenIndexFrom] = dx;\\n v.x =\\n (v.baseSwap.calculateTokenAmount(baseInputs, true) *\\n v.baseVirtualPrice) /\\n BASE_VIRTUAL_PRICE_PRECISION;\\n // when adding to the base pool,you pay approx 50% of the swap fee\\n v.x =\\n v.x -\\n ((v.x * _getBaseSwapFee(metaSwapStorage.baseSwap)) /\\n (FEE_DENOMINATOR * 2)) +\\n xp[v.baseLPTokenIndex];\\n } else {\\n // both from and to are from the base pool\\n return\\n v.baseSwap.calculateSwap(\\n tokenIndexFrom,\\n tokenIndexTo - v.baseLPTokenIndex,\\n dx\\n );\\n }\\n tokenIndexFrom = v.baseLPTokenIndex;\\n }\\n\\n v.metaIndexTo = v.baseLPTokenIndex;\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n v.metaIndexTo = tokenIndexTo;\\n }\\n\\n {\\n uint256 y = SwapUtilsV2.getY(\\n self._getAPrecise(),\\n tokenIndexFrom,\\n v.metaIndexTo,\\n v.x,\\n xp\\n );\\n v.dy = xp[v.metaIndexTo] - y - 1;\\n uint256 dyFee = (v.dy * self.swapFee) / FEE_DENOMINATOR;\\n v.dy = v.dy - dyFee;\\n }\\n\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n // tokenTo is from this pool\\n v.dy = v.dy / self.tokenPrecisionMultipliers[v.metaIndexTo];\\n } else {\\n // tokenTo is from the base pool\\n v.dy = v.baseSwap.calculateRemoveLiquidityOneToken(\\n (v.dy * BASE_VIRTUAL_PRICE_PRECISION) / v.baseVirtualPrice,\\n tokenIndexTo - v.baseLPTokenIndex\\n );\\n }\\n\\n return v.dy;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = self._getAPrecise();\\n uint256 d0;\\n uint256 d1;\\n {\\n uint256 baseVirtualPrice = _getBaseVirtualPrice(metaSwapStorage);\\n uint256[] memory balances1 = self.balances;\\n uint256[] memory tokenPrecisionMultipliers = self\\n .tokenPrecisionMultipliers;\\n uint256 numTokens = balances1.length;\\n d0 = SwapUtilsV2.getD(\\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\\n a\\n );\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (deposit) {\\n balances1[i] = balances1[i] + amounts[i];\\n } else {\\n if (amounts[i] > balances1[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = balances1[i] - amounts[i];\\n }\\n }\\n }\\n }\\n d1 = SwapUtilsV2.getD(\\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\\n a\\n );\\n }\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return ((d1 - d0) * totalSupply) / d0;\\n } else {\\n return ((d0 - d1) * totalSupply) / d0;\\n }\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n uint256 pooledTokensLength = self.pooledTokens.length;\\n require(\\n tokenIndexFrom < pooledTokensLength &&\\n tokenIndexTo < pooledTokensLength,\\n \\\"Token index is out of range\\\"\\n );\\n }\\n\\n uint256 transferredDx;\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n\\n {\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n transferredDx =\\n tokenFrom.balanceOf(address(this)) -\\n beforeBalance;\\n }\\n }\\n\\n (uint256 dy, uint256 dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n transferredDx,\\n _updateBaseVirtualPrice(metaSwapStorage)\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = (dyFee * self.adminFee) /\\n FEE_DENOMINATOR /\\n self.tokenPrecisionMultipliers[tokenIndexTo];\\n\\n self.balances[tokenIndexFrom] =\\n self.balances[tokenIndexFrom] +\\n transferredDx;\\n self.balances[tokenIndexTo] =\\n self.balances[tokenIndexTo] -\\n dy -\\n dyAdminFee;\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(\\n msg.sender,\\n transferredDx,\\n dy,\\n tokenIndexFrom,\\n tokenIndexTo\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Swaps with the underlying tokens of the base Swap pool. For this function,\\n * the token indices are flattened out so that underlying tokens are represented\\n * in the indices.\\n * @dev Since this calls multiple external functions during the execution,\\n * it is recommended to protect any function that depends on this with reentrancy guards.\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swapUnderlying(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n SwapUnderlyingInfo memory v = SwapUnderlyingInfo(\\n 0,\\n 0,\\n 0,\\n self.tokenPrecisionMultipliers,\\n self.balances,\\n metaSwapStorage.baseTokens,\\n IERC20(address(0)),\\n 0,\\n IERC20(address(0)),\\n 0,\\n _updateBaseVirtualPrice(metaSwapStorage)\\n );\\n\\n uint8 baseLPTokenIndex = uint8(v.oldBalances.length - 1);\\n\\n {\\n uint8 maxRange = uint8(baseLPTokenIndex + v.baseTokens.length);\\n require(\\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\\n \\\"Token index out of range\\\"\\n );\\n }\\n\\n ISwapV2 baseSwap = metaSwapStorage.baseSwap;\\n\\n // Find the address of the token swapping from and the index in MetaSwap's token list\\n if (tokenIndexFrom < baseLPTokenIndex) {\\n v.tokenFrom = self.pooledTokens[tokenIndexFrom];\\n v.metaIndexFrom = tokenIndexFrom;\\n } else {\\n v.tokenFrom = v.baseTokens[tokenIndexFrom - baseLPTokenIndex];\\n v.metaIndexFrom = baseLPTokenIndex;\\n }\\n\\n // Find the address of the token swapping to and the index in MetaSwap's token list\\n if (tokenIndexTo < baseLPTokenIndex) {\\n v.tokenTo = self.pooledTokens[tokenIndexTo];\\n v.metaIndexTo = tokenIndexTo;\\n } else {\\n v.tokenTo = v.baseTokens[tokenIndexTo - baseLPTokenIndex];\\n v.metaIndexTo = baseLPTokenIndex;\\n }\\n\\n // Check for possible fee on transfer\\n v.dx = v.tokenFrom.balanceOf(address(this));\\n v.tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n v.dx = v.tokenFrom.balanceOf(address(this)) - v.dx; // update dx in case of fee on transfer\\n\\n if (\\n tokenIndexFrom < baseLPTokenIndex || tokenIndexTo < baseLPTokenIndex\\n ) {\\n // Either one of the tokens belongs to the MetaSwap tokens list\\n uint256[] memory xp = _xp(\\n v.oldBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n );\\n\\n if (tokenIndexFrom < baseLPTokenIndex) {\\n // Swapping from a MetaSwap token\\n v.x =\\n xp[tokenIndexFrom] +\\n (dx * v.tokenPrecisionMultipliers[tokenIndexFrom]);\\n } else {\\n // Swapping from one of the tokens hosted in the base Swap\\n // This case requires adding the underlying token to the base Swap, then\\n // using the base LP token to swap to the desired token\\n uint256[] memory baseAmounts = new uint256[](\\n v.baseTokens.length\\n );\\n baseAmounts[tokenIndexFrom - baseLPTokenIndex] = v.dx;\\n\\n // Add liquidity to the base Swap contract and receive base LP token\\n v.dx = baseSwap.addLiquidity(baseAmounts, 0, block.timestamp);\\n\\n // Calculate the value of total amount of baseLPToken we end up with\\n v.x =\\n ((v.dx * v.baseVirtualPrice) /\\n BASE_VIRTUAL_PRICE_PRECISION) +\\n xp[baseLPTokenIndex];\\n }\\n\\n // Calculate how much to withdraw in MetaSwap level and the the associated swap fee\\n uint256 dyFee;\\n {\\n uint256 y = SwapUtilsV2.getY(\\n self._getAPrecise(),\\n v.metaIndexFrom,\\n v.metaIndexTo,\\n v.x,\\n xp\\n );\\n v.dy = xp[v.metaIndexTo] - y - 1;\\n if (tokenIndexTo >= baseLPTokenIndex) {\\n // When swapping to a base Swap token, scale down dy by its virtual price\\n v.dy =\\n (v.dy * BASE_VIRTUAL_PRICE_PRECISION) /\\n v.baseVirtualPrice;\\n }\\n dyFee = (v.dy * self.swapFee) / FEE_DENOMINATOR;\\n v.dy =\\n (v.dy - dyFee) /\\n v.tokenPrecisionMultipliers[v.metaIndexTo];\\n }\\n\\n // Update the balances array according to the calculated input and output amount\\n {\\n uint256 dyAdminFee = (dyFee * self.adminFee) / FEE_DENOMINATOR;\\n dyAdminFee =\\n dyAdminFee /\\n v.tokenPrecisionMultipliers[v.metaIndexTo];\\n self.balances[v.metaIndexFrom] =\\n v.oldBalances[v.metaIndexFrom] +\\n v.dx;\\n self.balances[v.metaIndexTo] =\\n v.oldBalances[v.metaIndexTo] -\\n v.dy -\\n dyAdminFee;\\n }\\n\\n if (tokenIndexTo >= baseLPTokenIndex) {\\n // When swapping to a token that belongs to the base Swap, burn the LP token\\n // and withdraw the desired token from the base pool\\n uint256 oldBalance = v.tokenTo.balanceOf(address(this));\\n baseSwap.removeLiquidityOneToken(\\n v.dy,\\n tokenIndexTo - baseLPTokenIndex,\\n 0,\\n block.timestamp\\n );\\n v.dy = v.tokenTo.balanceOf(address(this)) - oldBalance;\\n }\\n\\n // Check the amount of token to send meets minDy\\n require(v.dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n } else {\\n // Both tokens are from the base Swap pool\\n // Do a swap through the base Swap\\n v.dy = v.tokenTo.balanceOf(address(this));\\n baseSwap.swap(\\n tokenIndexFrom - baseLPTokenIndex,\\n tokenIndexTo - baseLPTokenIndex,\\n v.dx,\\n minDy,\\n block.timestamp\\n );\\n v.dy = v.tokenTo.balanceOf(address(this)) - v.dy;\\n }\\n\\n // Send the desired token to the caller\\n v.tokenTo.safeTransfer(msg.sender, v.dy);\\n\\n emit TokenSwapUnderlying(\\n msg.sender,\\n dx,\\n v.dy,\\n tokenIndexFrom,\\n tokenIndexTo\\n );\\n\\n return v.dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n self.lpToken,\\n 0,\\n self._getAPrecise(),\\n _updateBaseVirtualPrice(metaSwapStorage),\\n self.tokenPrecisionMultipliers,\\n self.balances\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = SwapUtilsV2.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n }\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] =\\n pooledTokens[i].balanceOf(address(this)) -\\n beforeBalance;\\n }\\n\\n v.newBalances[i] = v.newBalances[i] + amounts[i];\\n }\\n\\n // invariant after change\\n v.d1 = SwapUtilsV2.getD(\\n _xp(v.newBalances, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256 toMint;\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = SwapUtilsV2._feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * self.balances[i]) / v.d0;\\n fees[i] =\\n (feePerToken *\\n (idealBalance.difference(v.newBalances[i]))) /\\n FEE_DENOMINATOR;\\n self.balances[i] =\\n v.newBalances[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n v.newBalances[i] = v.newBalances[i] - fees[i];\\n }\\n v.d2 = SwapUtilsV2.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = v.newBalances;\\n toMint = v.d1;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n self.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply + toMint\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPTokenV2 lpToken = self.lpToken;\\n uint256 totalSupply = lpToken.totalSupply();\\n uint256 numTokens = self.pooledTokens.length;\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 dyFee;\\n uint256 dy;\\n\\n (dy, dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n _updateBaseVirtualPrice(metaSwapStorage),\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n // Update balances array\\n self.balances[tokenIndex] =\\n self.balances[tokenIndex] -\\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\\n\\n // Burn the associated LP token from the caller and send the desired token\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n self.pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n SwapUtilsV2.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n // Using this struct to avoid stack too deep error\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n self.lpToken,\\n 0,\\n self._getAPrecise(),\\n _updateBaseVirtualPrice(metaSwapStorage),\\n self.tokenPrecisionMultipliers,\\n self.balances\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n require(\\n amounts.length == v.newBalances.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n require(maxBurnAmount != 0, \\\"Must burn more than 0\\\");\\n\\n uint256 feePerToken = SwapUtilsV2._feePerToken(\\n self.swapFee,\\n v.newBalances.length\\n );\\n\\n // Calculate how much LPToken should be burned\\n uint256[] memory fees = new uint256[](v.newBalances.length);\\n {\\n uint256[] memory balances1 = new uint256[](v.newBalances.length);\\n\\n v.d0 = SwapUtilsV2.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n if (amounts[i] > v.newBalances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = v.newBalances[i] - amounts[i];\\n }\\n }\\n }\\n v.d1 = SwapUtilsV2.getD(\\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n uint256 idealBalance = (v.d1 * v.newBalances[i]) / v.d0;\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\\n self.balances[i] =\\n balances1[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n balances1[i] = balances1[i] - fees[i];\\n }\\n\\n v.d2 = SwapUtilsV2.getD(\\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n }\\n\\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n\\n // Scale up by withdraw fee\\n tokenAmount = tokenAmount + 1;\\n\\n // Check for max burn amount\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n // Burn the calculated amount of LPToken from the caller and send the desired tokens\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply - tokenAmount\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice Determines if the stored value of base Swap's virtual price is expired.\\n * If the last update was past the BASE_CACHE_EXPIRE_TIME, then update the stored value.\\n *\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @return base Swap's virtual price\\n */\\n function _updateBaseVirtualPrice(MetaSwap storage metaSwapStorage)\\n internal\\n returns (uint256)\\n {\\n if (\\n block.timestamp >\\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\\n ) {\\n // When the cache is expired, update it\\n uint256 baseVirtualPrice = ISwapV2(metaSwapStorage.baseSwap)\\n .getVirtualPrice();\\n metaSwapStorage.baseVirtualPrice = baseVirtualPrice;\\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\\n return baseVirtualPrice;\\n } else {\\n return metaSwapStorage.baseVirtualPrice;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9f7e54b65a0cbce64d870e6c85f175f510064fe2419fbcdb99faba1bfd50e83b\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x61508661003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100de5760003560e01c8063698e6ff41161008b578063becf967c11610065578063becf967c146101d0578063c76e4492146101d9578063c9f0fca8146101f957600080fd5b8063698e6ff4146101815780636dca1c05146101a1578063a28c2341146101c157600080fd5b8063631f06fc116100bc578063631f06fc1461014857806368d5af9e1461015b578063694437401461016e57600080fd5b80630f6a2291146100e357806321056a00146101155780636023759814610128575b600080fd5b8180156100ef57600080fd5b506101036100fe366004614a0e565b61020c565b60405190815260200160405180910390f35b610103610123366004614a66565b610f5c565b81801561013457600080fd5b50610103610143366004614ae3565b610f7e565b610103610156366004614bda565b6118fe565b610103610169366004614bfc565b611a81565b61010361017c366004614a66565b611b1a565b81801561018d57600080fd5b5061010361019c366004614a0e565b6120e9565b8180156101ad57600080fd5b506101036101bc366004614c3b565b612579565b610103670de0b6b3a764000081565b61010361025881565b8180156101e557600080fd5b506101036101f4366004614ae3565b612908565b610103610207366004614c82565b6130e3565b6000806040518061016001604052806000815260200160008152602001600081526020018960080180548060200260200160405190810160405280929190818152602001828054801561027e57602002820191906000526020600020905b81548152602001906001019080831161026a575b50505050508152602001896009018054806020026020016040519081016040528092919081815260200182805480156102d657602002820191906000526020600020905b8154815260200190600101908083116102c2575b505050505081526020018860030180548060200260200160405190810160405280929190818152602001828054801561033857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161031a575b50505091835250506000602082018190526040820181905260608201819052608082015260a00161036889613417565b8152509050600060018260800151516103819190614d4f565b905060008260a00151518260ff166103999190614d62565b90508060ff168860ff161080156103b557508060ff168760ff16105b6104065760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064015b60405180910390fd5b5087546001600160a01b031660ff808316908916101561046057896007018860ff168154811061043857610438614d75565b6000918252602090912001546001600160a01b031660c084015260ff881660e08401526104a5565b60a083015161046f838a614da4565b60ff168151811061048257610482614d75565b60209081029190910101516001600160a01b031660c084015260ff821660e08401525b8160ff168760ff1610156104f557896007018760ff16815481106104cb576104cb614d75565b6000918252602090912001546001600160a01b031661010084015260ff871661012084015261053c565b60a08301516105048389614da4565b60ff168151811061051757610517614d75565b60209081029190910101516001600160a01b031661010084015260ff82166101208401525b60c08301516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561059f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c39190614dbd565b602084015260c08301516105e2906001600160a01b03163330896134dd565b602083015160c08401516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561064a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066e9190614dbd565b6106789190614d4f565b602084015260ff808316908916108061069657508160ff168760ff16105b15610ce85760006106b5846080015185606001518661014001516135b2565b90508260ff168960ff16101561071f5783606001518960ff16815181106106de576106de614d75565b6020026020010151876106f19190614dd6565b818a60ff168151811061070657610706614d75565b60200260200101516107189190614d62565b8452610881565b60008460a001515167ffffffffffffffff81111561073f5761073f614ab4565b604051908082528060200260200182016040528015610768578160200160208202803683370190505b5060208601519091508161077c868d614da4565b60ff168151811061078f5761078f614d75565b60209081029190910101526040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b03841690634d49e87d906107e49084906000904290600401614e28565b6020604051808303816000875af1158015610803573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108279190614dbd565b60208601528151829060ff861690811061084357610843614d75565b6020026020010151670de0b6b3a764000086610140015187602001516108699190614dd6565b6108739190614e4d565b61087d9190614d62565b8552505b6000806108a36108908e613634565b60e08801516101208901518951876136db565b90506001818488610120015160ff16815181106108c2576108c2614d75565b60200260200101516108d49190614d4f565b6108de9190614d4f565b604087015260ff808616908b161061091e57856101400151670de0b6b3a7640000876040015161090e9190614dd6565b6109189190614e4d565b60408701525b6402540be4008d6004015487604001516109389190614dd6565b6109429190614e4d565b9150856060015186610120015160ff168151811061096257610962614d75565b602002602001015182876040015161097a9190614d4f565b6109849190614e4d565b60408701525060058c01546000906402540be400906109a39084614dd6565b6109ad9190614e4d565b9050856060015186610120015160ff16815181106109cd576109cd614d75565b6020026020010151816109e09190614e4d565b9050856020015186608001518760e0015160ff1681518110610a0457610a04614d75565b6020026020010151610a169190614d62565b8d6009018760e0015160ff1681548110610a3257610a32614d75565b9060005260206000200181905550808660400151876080015188610120015160ff1681518110610a6457610a64614d75565b6020026020010151610a769190614d4f565b610a809190614d4f565b8d60090187610120015160ff1681548110610a9d57610a9d614d75565b9060005260206000200181905550508360ff168960ff1610610c8d576101008501516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610b1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b429190614dbd565b9050836001600160a01b0316633e3a15608760400151878d610b649190614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152600060448201524260648201526084016020604051808303816000875af1158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190614dbd565b506101008601516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c9190614dbd565b610c869190614d4f565b6040870152505b8685604001511015610ce15760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e7360448201526064016103fd565b5050610ed2565b6101008301516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610d4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d709190614dbd565b60408401526001600160a01b0381166391695586610d8e848b614da4565b610d98858b614da4565b60208701516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b16815260ff938416600482015292909116602483015260448201526064810188905242608482015260a4016020604051808303816000875af1158015610e10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e349190614dbd565b5060408084015161010085015191517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290916001600160a01b0316906370a0823190602401602060405180830381865afa158015610e9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec29190614dbd565b610ecc9190614d4f565b60408401525b610ef93384604001518561010001516001600160a01b03166139629092919063ffffffff16565b6040838101518151888152602081019190915260ff8a81168284015289166060820152905133917f6617207207e397b41fc98016d8c9febb7223f44c355db66ad429730f2b950a60919081900360800190a2505060400151979650505050505050565b6000610f7386858585610f6e8a6139b0565b613a51565b509695505050505050565b60008085600701805480602002602001604051908101604052809291908181526020018280548015610fd957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fbb575b5050505050905080518451146110315760405162461bcd60e51b815260206004820181905260248201527f416d6f756e7473206d757374206d6174636820706f6f6c656420746f6b656e7360448201526064016103fd565b6000815167ffffffffffffffff81111561104d5761104d614ab4565b604051908082528060200260200182016040528015611076578160200160208202803683370190505b50604080516101208101825260008082526020820181905291810182905260068a01546001600160a01b03166060820152608081018290529192509060a081016110bf8a613634565b81526020016110cd89613417565b81526020018960080180548060200260200160405190810160405280929190818152602001828054801561112057602002820191906000526020600020905b81548152602001906001019080831161110c575b505050505081526020018960090180548060200260200160405190810160405280929190818152602001828054801561117857602002820191906000526020600020905b815481526020019060010190808311611164575b5050505050815250905080606001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e89190614dbd565b608082018190521561121c5761121961120f8261010001518360e001518460c001516135b2565b8260a00151613c41565b81525b60005b83518110156114f65760808201511515806112535750600087828151811061124957611249614d75565b6020026020010151115b61129f5760405162461bcd60e51b815260206004820152601e60248201527f4d75737420737570706c7920616c6c20746f6b656e7320696e20706f6f6c000060448201526064016103fd565b8681815181106112b1576112b1614d75565b602002602001015160001461147f5760008482815181106112d4576112d4614d75565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561133d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113619190614dbd565b90506113b533308a858151811061137a5761137a614d75565b602002602001015188868151811061139457611394614d75565b60200260200101516001600160a01b03166134dd909392919063ffffffff16565b808583815181106113c8576113c8614d75565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190614dbd565b61145f9190614d4f565b88838151811061147157611471614d75565b602002602001018181525050505b86818151811061149157611491614d75565b602002602001015182610100015182815181106114b0576114b0614d75565b60200260200101516114c29190614d62565b82610100015182815181106114d9576114d9614d75565b6020908102919091010152806114ee81614e88565b91505061121f565b5061151261120f8261010001518360e001518460c001516135b2565b602082018190528151106115685760405162461bcd60e51b815260206004820152601160248201527f442073686f756c6420696e63726561736500000000000000000000000000000060448201526064016103fd565b602081015160408201526080810151600090156117a35760006115908a600401548651613e16565b905060005b855181101561174657600084600001518c60090183815481106115ba576115ba614d75565b906000526020600020015486602001516115d49190614dd6565b6115de9190614e4d565b90506402540be400611617866101000151848151811061160057611600614d75565b602002602001015183613e4290919063ffffffff16565b6116219085614dd6565b61162b9190614e4d565b86838151811061163d5761163d614d75565b6020026020010181815250506402540be4008c6005015487848151811061166657611666614d75565b60200260200101516116789190614dd6565b6116829190614e4d565b856101000151838151811061169957611699614d75565b60200260200101516116ab9190614d4f565b8c60090183815481106116c0576116c0614d75565b90600052602060002001819055508582815181106116e0576116e0614d75565b602002602001015185610100015183815181106116ff576116ff614d75565b60200260200101516117119190614d4f565b856101000151838151811061172857611728614d75565b6020908102919091010152508061173e81614e88565b915050611595565b5061176c6117628461010001518560e001518660c001516135b2565b8460a00151613c41565b60408401819052835160808501519091611787908390614d4f565b6117919190614dd6565b61179b9190614e4d565b9150506117c7565b61010082015180516117bf9160098c019160209091019061499d565b505060208101515b858110156118175760405162461bcd60e51b815260206004820152601b60248201527f436f756c646e2774206d696e74206d696e20726571756573746564000000000060448201526064016103fd565b60068901546040517f40c10f19000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b15801561187e57600080fd5b505af1158015611892573d6000803e3d6000fd5b50505050336001600160a01b03167f189c623b666b1b45b83d7178f39b8c087cb09774317ca2f53c2d3c3726f222a2888585602001518587608001516118d89190614d62565b6040516118e89493929190614ec0565b60405180910390a293505050505b949350505050565b6000806119c96119bb8560090180548060200260200160405190810160405280929190818152602001828054801561195557602002820191906000526020600020905b815481526020019060010190808311611941575b5050505050866008018054806020026020016040519081016040528092919081815260200182805480156119a857602002820191906000526020600020905b815481526020019060010190808311611994575b50505050506119b6876139b0565b6135b2565b6119c486613634565b613c41565b905060008460060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a469190614dbd565b90508015611a745780611a61670de0b6b3a764000084614dd6565b611a6b9190614e4d565b92505050611a7b565b6000925050505b92915050565b6000611b10858484611a92886139b0565b8960060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0b9190614dbd565b613e67565b5095945050505050565b6000806040518060e00160405280611b31886139b0565b815287546001600160a01b03166020820152600060408201819052600389015460ff1660608301526080820181905260a0820181905260c0909101819052815191925090611b80908990613ede565b905060018151611b909190614d4f565b60ff16604083018190526060830151600091611bac9190614ef9565b90508060ff168760ff16108015611bc857508060ff168660ff16105b611c145760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b50816040015160ff168660ff161015611c8657876008018660ff1681548110611c3f57611c3f614d75565b906000526020600020015484611c559190614dd6565b818760ff1681518110611c6a57611c6a614d75565b6020026020010151611c7c9190614d62565b60a0830152611ef7565b6040820151611c959087614da4565b9550816040015160ff168560ff161015611e3a576000826060015160ff1667ffffffffffffffff811115611ccb57611ccb614ab4565b604051908082528060200260200182016040528015611cf4578160200160208202803683370190505b50905084818860ff1681518110611d0d57611d0d614d75565b602002602001018181525050670de0b6b3a7640000836000015184602001516001600160a01b031663e6ab28068460016040518363ffffffff1660e01b8152600401611d5a929190614f12565b602060405180830381865afa158015611d77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9b9190614dbd565b611da59190614dd6565b611daf9190614e4d565b60a084015260408301518251839160ff16908110611dcf57611dcf614d75565b60200260200101516402540be4006002611de99190614dd6565b8954611dfd906001600160a01b0316613f8f565b8560a00151611e0c9190614dd6565b611e169190614e4d565b8460a00151611e259190614d4f565b611e2f9190614d62565b60a084015250611eef565b81602001516001600160a01b031663a95b089f87846040015188611e5e9190614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260ff92831660048201529116602482015260448101879052606401602060405180830381865afa158015611ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee69190614dbd565b925050506120e0565b816040015195505b604082015160ff908116608084018190529086161015611f1b5760ff851660808301525b6000611f3a611f298a613634565b8885608001518660a00151866136db565b905060018183856080015160ff1681518110611f5857611f58614d75565b6020026020010151611f6a9190614d4f565b611f749190614d4f565b60c0840181905260048a01546000916402540be40091611f9391614dd6565b611f9d9190614e4d565b9050808460c00151611faf9190614d4f565b60c08501525050604082015160ff90811690861610156120095787600801826080015160ff1681548110611fe557611fe5614d75565b90600052602060002001548260c00151611fff9190614e4d565b60c08301526120d8565b81602001516001600160a01b031663342a87a18360000151670de0b6b3a76400008560c001516120399190614dd6565b6120439190614e4d565b60408501516120529089614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604401602060405180830381865afa1580156120ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d29190614dbd565b60c08301525b5060c0015190505b95945050505050565b600786015460009060ff8616811180156121055750808560ff16105b6121515760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20696e646578206973206f7574206f662072616e6765000000000060448201526064016103fd565b50600080886007018760ff168154811061216d5761216d614d75565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116915081906370a0823190602401602060405180830381865afa1580156121da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fe9190614dbd565b85111561224d5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073776170206d6f7265207468616e20796f75206f776e00000060448201526064016103fd565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156122ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d19190614dbd565b90506122e86001600160a01b0383163330896134dd565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015612347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236b9190614dbd565b6123759190614d4f565b9250505060008061238c8a898986610f6e8e613417565b91509150848210156123e05760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e7360448201526064016103fd565b60008a6008018860ff16815481106123fa576123fa614d75565b90600052602060002001546402540be4008c600501548461241b9190614dd6565b6124259190614e4d565b61242f9190614e4d565b9050838b6009018a60ff168154811061244a5761244a614d75565b906000526020600020015461245f9190614d62565b8b6009018a60ff168154811061247757612477614d75565b906000526020600020018190555080838c6009018a60ff168154811061249f5761249f614d75565b90600052602060002001546124b49190614d4f565b6124be9190614d4f565b8b6009018960ff16815481106124d6576124d6614d75565b906000526020600020018190555061251d33848d6007018b60ff168154811061250157612501614d75565b6000918252602090912001546001600160a01b03169190613962565b604080518581526020810185905260ff8b8116828401528a166060820152905133917fc6c1e0630dbe9130cc068028486c0d118ddcea348550819defd5cb8c257f8a38919081900360800190a250909998505050505050505050565b6006850154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691839183916318160ddd9160048083019260209291908290030181865afa1580156125e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126069190614dbd565b60078901546040517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152919250906001600160a01b038416906370a0823190602401602060405180830381865afa15801561266c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126909190614dbd565b8711156126df5760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f660000000000000000000000000000000000000060448201526064016103fd565b808660ff16106127315760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e64000000000000000000000000000000000060448201526064016103fd565b6000806127498b8a8a6127438e613417565b88613e67565b925090508681101561279d5760405162461bcd60e51b815260206004820152600e60248201527f6479203c206d696e416d6f756e7400000000000000000000000000000000000060448201526064016103fd565b6402540be4008b60050154836127b39190614dd6565b6127bd9190614e4d565b6127c79082614d62565b8b6009018960ff16815481106127df576127df614d75565b90600052602060002001546127f49190614d4f565b8b6009018960ff168154811061280c5761280c614d75565b6000918252602090912001556040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b15801561287957600080fd5b505af115801561288d573d6000803e3d6000fd5b505050506128ae33828d6007018b60ff168154811061250157612501614d75565b604080518a81526020810186905260ff8a168183015260608101839052905133917f43fb02998f4e03da2e0e6fff53fdbf0c40a9f45f145dc377fc30615d7d7a8a64919081900360800190a29a9950505050505050505050565b604080516101208101825260008082526020820181905291810182905260068601546001600160a01b0316606082015260808101829052819060a0810161294e88613634565b815260200161295c87613417565b8152602001876008018054806020026020016040519081016040528092919081815260200182805480156129af57602002820191906000526020600020905b81548152602001906001019080831161299b575b5050505050815260200187600901805480602002602001604051908101604052809291908181526020018280548015612a0757602002820191906000526020600020905b8154815260200190600101908083116129f3575b5050505050815250905080606001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a779190614dbd565b608082015261010081015151845114612ad25760405162461bcd60e51b815260206004820181905260248201527f416d6f756e74732073686f756c64206d6174636820706f6f6c20746f6b656e7360448201526064016103fd565b82600003612b225760405162461bcd60e51b815260206004820152601560248201527f4d757374206275726e206d6f7265207468616e2030000000000000000000000060448201526064016103fd565b6000612b38876004015483610100015151613e16565b905060008261010001515167ffffffffffffffff811115612b5b57612b5b614ab4565b604051908082528060200260200182016040528015612b84578160200160208202803683370190505b50905060008361010001515167ffffffffffffffff811115612ba857612ba8614ab4565b604051908082528060200260200182016040528015612bd1578160200160208202803683370190505b509050612bf9612bef8561010001518660e001518760c001516135b2565b8560a00151613c41565b845260005b84610100015151811015612d23578461010001518181518110612c2357612c23614d75565b6020026020010151888281518110612c3d57612c3d614d75565b60200260200101511115612cb95760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c65000000000000000000000000000000000000000000000000000000000060648201526084016103fd565b878181518110612ccb57612ccb614d75565b60200260200101518561010001518281518110612cea57612cea614d75565b602002602001015103828281518110612d0557612d05614d75565b60200260200101818152505080612d1b81614e88565b915050612bfe565b50612d3a612bef828660e001518760c001516135b2565b602085015260005b84610100015151811015612ed357600085600001518661010001518381518110612d6e57612d6e614d75565b60200260200101518760200151612d859190614dd6565b612d8f9190614e4d565b90506000612da884848151811061160057611600614d75565b90506402540be400612dba8288614dd6565b612dc49190614e4d565b858481518110612dd657612dd6614d75565b6020026020010181815250506402540be4008c60050154868581518110612dff57612dff614d75565b6020026020010151612e119190614dd6565b612e1b9190614e4d565b848481518110612e2d57612e2d614d75565b6020026020010151612e3f9190614d4f565b8c6009018481548110612e5457612e54614d75565b9060005260206000200181905550848381518110612e7457612e74614d75565b6020026020010151848481518110612e8e57612e8e614d75565b6020026020010151612ea09190614d4f565b848481518110612eb257612eb2614d75565b60200260200101818152505050508080612ecb90614e88565b915050612d42565b50612eea612bef828660e001518760c001516135b2565b6040850181905284516080860151600093509091612f089083614d4f565b612f129190614dd6565b612f1c9190614e4d565b905080600003612f6e5760405162461bcd60e51b815260206004820152601b60248201527f4275726e7420616d6f756e742063616e6e6f74206265207a65726f000000000060448201526064016103fd565b612f79816001614d62565b905085811115612fcb5760405162461bcd60e51b815260206004820152601b60248201527f746f6b656e416d6f756e74203e206d61784275726e416d6f756e74000000000060448201526064016103fd565b60608401516040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561303257600080fd5b505af1158015613046573d6000803e3d6000fd5b5050505060005b846101000151518110156130a05761308e3389838151811061307157613071614d75565b60200260200101518c600701848154811061250157612501614d75565b8061309881614e88565b91505061304d565b50336001600160a01b03167f3631c28b1f9dd213e0319fb167b554d76b6c283a41143eb400a0d1adb1af1755888487602001518589608001516118d89190614d4f565b6000806130ef87613634565b905060008060006130ff896139b0565b905060008a60090180548060200260200160405190810160405280929190818152602001828054801561315157602002820191906000526020600020905b81548152602001906001019080831161313d575b5050505050905060008b6008018054806020026020016040519081016040528092919081815260200182805480156131a857602002820191906000526020600020905b815481526020019060010190808311613194575b505050505090506000825190506131c96131c38484876135b2565b88613c41565b955060005b8181101561334857891561323c578b8b828181106131ee576131ee614d75565b9050602002013584828151811061320757613207614d75565b60200260200101516132199190614d62565b84828151811061322b5761322b614d75565b602002602001018181525050613336565b83818151811061324e5761324e614d75565b60200260200101518c8c8381811061326857613268614d75565b9050602002013511156132e35760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c65000000000000000000000000000000000000000000000000000000000060648201526084016103fd565b8b8b828181106132f5576132f5614d75565b9050602002013584828151811061330e5761330e614d75565b60200260200101510384828151811061332957613329614d75565b6020026020010181815250505b8061334081614e88565b9150506131ce565b506133576131c38484876135b2565b94505050505060008960060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d89190614dbd565b9050851561340b5782816133ec8285614d4f565b6133f69190614dd6565b6134009190614e4d565b9450505050506120e0565b82816133ec8483614d4f565b6000610258826002015461342b9190614d62565b4211156134d0578154604080517fe25aa5fa00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163e25aa5fa9160048083019260209291908290030181865afa158015613494573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134b89190614dbd565b60018401819055426002909401939093555090919050565b506001015490565b919050565b6040516001600160a01b03808516602483015283166044820152606481018290526135ac9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614000565b50505050565b606060006135c085856140e5565b90506000600186516135d29190614d4f565b9050670de0b6b3a7640000848383815181106135f0576135f0614d75565b60200260200101516136029190614dd6565b61360c9190614e4d565b82828151811061361e5761361e614d75565b60209081029190910101525090505b9392505050565b60038101546001820154600091904282111561362d57600284015484548083111561369f576136638285614d4f565b61366d8342614d4f565b6136778386614d4f565b6136819190614dd6565b61368b9190614e4d565b6136959082614d62565b9695505050505050565b6136a98285614d4f565b6136b38342614d4f565b6136bd8584614d4f565b6136c79190614dd6565b6136d19190614e4d565b6136959082614d4f565b805160009060ff808616908716036137355760405162461bcd60e51b815260206004820152601d60248201527f43616e277420636f6d7061726520746f6b656e20746f20697473656c6600000060448201526064016103fd565b808660ff161080156137495750808560ff16105b6137955760405162461bcd60e51b815260206004820152601660248201527f546f6b656e73206d75737420626520696e20706f6f6c0000000000000000000060448201526064016103fd565b60006137a18489613c41565b9050806000806137b18b86614dd6565b90506000805b86811015613840578b60ff1681036137d157899150613801565b8a60ff1681146137fc578881815181106137ed576137ed614d75565b60200260200101519150613801565b61382e565b61380b8285614d62565b93506138178783614dd6565b6138218787614dd6565b61382b9190614e4d565b94505b8061383881614e88565b9150506137b7565b5061384b8683614dd6565b60646138578787614dd6565b6138619190614dd6565b61386b9190614e4d565b935060008261387b606488614dd6565b6138859190614e4d565b61388f9085614d62565b9050600086815b6101008110156139195781925088848360026138b29190614dd6565b6138bc9190614d62565b6138c69190614d4f565b886138d18480614dd6565b6138db9190614d62565b6138e59190614e4d565b91506138f18284614203565b15613907575098506120e0975050505050505050565b8061391181614e88565b915050613896565b5060405162461bcd60e51b815260206004820152601e60248201527f417070726f78696d6174696f6e20646964206e6f7420636f6e7665726765000060448201526064016103fd565b6040516001600160a01b0383166024820152604481018290526139ab9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161352a565b505050565b600061025882600201546139c49190614d62565b4211156134d0578154604080517fe25aa5fa00000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163e25aa5fa916004808201926020929091908290030181865afa158015613a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7b9190614dbd565b6000806000613a608885613ede565b905080518760ff16108015613a78575080518660ff16105b613ac45760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b600060018251613ad49190614d4f565b90506000896008018960ff1681548110613af057613af0614d75565b906000526020600020015487613b069190614dd6565b9050818960ff1603613b3257670de0b6b3a7640000613b258783614dd6565b613b2f9190614e4d565b90505b828960ff1681518110613b4757613b47614d75565b602002602001015181613b5a9190614d62565b90506000613b73613b6a8c613634565b8b8b85886136db565b9050600181858b60ff1681518110613b8d57613b8d614d75565b6020026020010151613b9f9190614d4f565b613ba99190614d4f565b9550828960ff1603613bd55786613bc8670de0b6b3a764000088614dd6565b613bd29190614e4d565b95505b6402540be4008b6004015487613beb9190614dd6565b613bf59190614e4d565b9450613c018587614d4f565b95508a6008018960ff1681548110613c1b57613c1b614d75565b906000526020600020015486613c319190614e4d565b9550505050509550959350505050565b815160009081805b82811015613c8a57858181518110613c6357613c63614d75565b602002602001015182613c769190614d62565b915080613c8281614e88565b915050613c49565b5080600003613c9e57600092505050611a7b565b60008181613cac8588614dd6565b905060005b610100811015613dcd578260005b87811015613d1457878b8281518110613cda57613cda614d75565b6020026020010151613cec9190614dd6565b613cf68684614dd6565b613d009190614e4d565b915080613d0c81614e88565b915050613cbf565b5083945080876001613d269190614d62565b613d309190614dd6565b606485613d3d8287614d4f565b613d479190614dd6565b613d519190614e4d565b613d5b9190614d62565b84613d668984614dd6565b6064613d728a88614dd6565b613d7c9190614e4d565b613d869190614d62565b613d909190614dd6565b613d9a9190614e4d565b9350613da68486614203565b15613dba5783975050505050505050611a7b565b5080613dc581614e88565b915050613cb1565b5060405162461bcd60e51b815260206004820152601360248201527f4420646f6573206e6f7420636f6e76657267650000000000000000000000000060448201526064016103fd565b6000613e23600183614d4f565b613e2e906004614dd6565b613e388385614dd6565b61362d9190614e4d565b600081831115613e5d57613e568284614d4f565b9050611a7b565b61362d8383614d4f565b600080600080600080613e7d8b8a8c8b8b61421a565b60088e018054939750909450909250859160ff8c16908110613ea157613ea1614d75565b90600052602060002001548284613eb89190614d4f565b613ec29190614e4d565b613ecc9190614d4f565b939b939a509298505050505050505050565b606061362d83600901805480602002602001604051908101604052809291908181526020018280548015613f3157602002820191906000526020600020905b815481526020019060010190808311613f1d575b505050505084600801805480602002602001604051908101604052809291908181526020018280548015613f8457602002820191906000526020600020905b815481526020019060010190808311613f70575b5050505050846135b2565b6000816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e060405180830381865afa158015613fcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ff39190614f36565b5090979650505050505050565b6000614055826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166146459092919063ffffffff16565b8051909150156139ab57808060200190518101906140739190614fa2565b6139ab5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103fd565b8151815160609190811461413b5760405162461bcd60e51b815260206004820152601f60248201527f42616c616e636573206d757374206d61746368206d756c7469706c696572730060448201526064016103fd565b60008167ffffffffffffffff81111561415657614156614ab4565b60405190808252806020026020018201604052801561417f578160200160208202803683370190505b50905060005b828110156141fa5784818151811061419f5761419f614d75565b60200260200101518682815181106141b9576141b9614d75565b60200260200101516141cb9190614dd6565b8282815181106141dd576141dd614d75565b6020908102919091010152806141f281614e88565b915050614185565b50949350505050565b600060016142118484613e42565b11159392505050565b60008060008061422a8987613ede565b905080518860ff161061427f5760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b60006040518060c00160405280600081526020016000815260200160008152602001600081526020016142b18c613634565b8152602001600081525090506142cb828260800151613c41565b80825286906142da908a614dd6565b6142e49190614e4d565b81516142f09190614d4f565b60208201528151829060ff8b1690811061430c5761430c614d75565b60200260200101518811156143635760405162461bcd60e51b815260206004820152601a60248201527f5769746864726177206578636565647320617661696c61626c6500000000000060448201526064016103fd565b61437781608001518a848460200151614654565b6040820152815160009067ffffffffffffffff81111561439957614399614ab4565b6040519080825280602002602001820160405280156143c2578160200160208202803683370190505b5090506143d48b600401548451613e16565b606083015260005b83518110156144d2578381815181106143f7576143f7614d75565b60200260200101518360a00181815250506402540be40083606001518c60ff168314614451578451602086015160a08701516144339190614dd6565b61443d9190614e4d565b8560a0015161444c9190614d4f565b614480565b60408501518551602087015160a088015161446c9190614dd6565b6144769190614e4d565b6144809190614d4f565b61448a9190614dd6565b6144949190614e4d565b8360a001516144a39190614d4f565b8282815181106144b5576144b5614d75565b6020908102919091010152806144ca81614e88565b9150506143dc565b5060006144e983608001518c848660200151614654565b828c60ff16815181106144fe576144fe614d75565b60200260200101516145109190614d4f565b9050600184516145209190614d4f565b8b60ff16036145d1578861453c670de0b6b3a764000083614dd6565b6145469190614e4d565b905088670de0b6b3a764000084604001516145619190614dd6565b61456b9190614e4d565b83604001818152505088670de0b6b3a7640000858d60ff168151811061459357614593614d75565b60200260200101516145a59190614dd6565b6145af9190614e4d565b848c60ff16815181106145c4576145c4614d75565b6020026020010181815250505b8b6008018b60ff16815481106145e9576145e9614d75565b90600052602060002001546001826146019190614d4f565b61460b9190614e4d565b9050808360400151858d60ff168151811061462857614628614d75565b602002602001015196509650965050505050955095509592505050565b60606118f6848460008561481c565b815160009060ff851681116146ab5760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e64000000000000000000000000000000000060448201526064016103fd565b826000806146b9848a614dd6565b905060005b84811015614745578860ff168114614733578781815181106146e2576146e2614d75565b6020026020010151836146f59190614d62565b92508488828151811061470a5761470a614d75565b602002602001015161471c9190614dd6565b6147268886614dd6565b6147309190614e4d565b93505b8061473d81614e88565b9150506146be565b506147508482614dd6565b606461475c8886614dd6565b6147669190614dd6565b6147709190614e4d565b9250600081614780606489614dd6565b61478a9190614e4d565b6147949084614d62565b9050600087815b6101008110156139195781925089848360026147b79190614dd6565b6147c19190614d62565b6147cb9190614d4f565b876147d68480614dd6565b6147e09190614d62565b6147ea9190614e4d565b91506147f68284614203565b1561480a575096506118f695505050505050565b8061481481614e88565b91505061479b565b6060824710156148945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103fd565b6001600160a01b0385163b6148eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103fd565b600080866001600160a01b031685876040516149079190614fe3565b60006040518083038185875af1925050503d8060008114614944576040519150601f19603f3d011682016040523d82523d6000602084013e614949565b606091505b5091509150614959828286614964565b979650505050505050565b6060831561497357508161362d565b8251156149835782518084602001fd5b8160405162461bcd60e51b81526004016103fd9190614fff565b8280548282559060005260206000209081019282156149d8579160200282015b828111156149d85782518255916020019190600101906149bd565b506149e49291506149e8565b5090565b5b808211156149e457600081556001016149e9565b803560ff811681146134d857600080fd5b60008060008060008060c08789031215614a2757600080fd5b8635955060208701359450614a3e604088016149fd565b9350614a4c606088016149fd565b92506080870135915060a087013590509295509295509295565b600080600080600060a08688031215614a7e57600080fd5b8535945060208601359350614a95604087016149fd565b9250614aa3606087016149fd565b949793965091946080013592915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060008060808587031215614af957600080fd5b843593506020808601359350604086013567ffffffffffffffff80821115614b2057600080fd5b818801915088601f830112614b3457600080fd5b813581811115614b4657614b46614ab4565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715614b8957614b89614ab4565b60405291825284820192508381018501918b831115614ba757600080fd5b938501935b82851015614bc557843584529385019392850192614bac565b989b979a509798606001359750505050505050565b60008060408385031215614bed57600080fd5b50508035926020909101359150565b60008060008060808587031215614c1257600080fd5b843593506020850135925060408501359150614c30606086016149fd565b905092959194509250565b600080600080600060a08688031215614c5357600080fd5b853594506020860135935060408601359250614aa3606087016149fd565b8015158114614c7f57600080fd5b50565b600080600080600060808688031215614c9a57600080fd5b8535945060208601359350604086013567ffffffffffffffff80821115614cc057600080fd5b818801915088601f830112614cd457600080fd5b813581811115614ce357600080fd5b8960208260051b8501011115614cf857600080fd5b6020830195508094505050506060860135614d1281614c71565b809150509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611a7b57611a7b614d20565b80820180821115611a7b57611a7b614d20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60ff8281168282160390811115611a7b57611a7b614d20565b600060208284031215614dcf57600080fd5b5051919050565b8082028115828204841417611a7b57611a7b614d20565b600081518084526020808501945080840160005b83811015614e1d57815187529582019590820190600101614e01565b509495945050505050565b606081526000614e3b6060830186614ded565b60208301949094525060400152919050565b600082614e83577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614eb957614eb9614d20565b5060010190565b608081526000614ed36080830187614ded565b8281036020840152614ee58187614ded565b604084019590955250506060015292915050565b60ff8181168382160190811115611a7b57611a7b614d20565b604081526000614f256040830185614ded565b905082151560208301529392505050565b600080600080600080600060e0888a031215614f5157600080fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c08801516001600160a01b0381168114614f9257600080fd5b8091505092959891949750929550565b600060208284031215614fb457600080fd5b815161362d81614c71565b60005b83811015614fda578181015183820152602001614fc2565b50506000910152565b60008251614ff5818460208701614fbf565b9190910192915050565b602081526000825180602084015261501e816040850160208701614fbf565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea26469706673582212209bc4c95d126ff94844fe591d872d4eed1e12df4f9a361a24eb726740e13d22b364736f6c63430008110033", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100de5760003560e01c8063698e6ff41161008b578063becf967c11610065578063becf967c146101d0578063c76e4492146101d9578063c9f0fca8146101f957600080fd5b8063698e6ff4146101815780636dca1c05146101a1578063a28c2341146101c157600080fd5b8063631f06fc116100bc578063631f06fc1461014857806368d5af9e1461015b578063694437401461016e57600080fd5b80630f6a2291146100e357806321056a00146101155780636023759814610128575b600080fd5b8180156100ef57600080fd5b506101036100fe366004614a0e565b61020c565b60405190815260200160405180910390f35b610103610123366004614a66565b610f5c565b81801561013457600080fd5b50610103610143366004614ae3565b610f7e565b610103610156366004614bda565b6118fe565b610103610169366004614bfc565b611a81565b61010361017c366004614a66565b611b1a565b81801561018d57600080fd5b5061010361019c366004614a0e565b6120e9565b8180156101ad57600080fd5b506101036101bc366004614c3b565b612579565b610103670de0b6b3a764000081565b61010361025881565b8180156101e557600080fd5b506101036101f4366004614ae3565b612908565b610103610207366004614c82565b6130e3565b6000806040518061016001604052806000815260200160008152602001600081526020018960080180548060200260200160405190810160405280929190818152602001828054801561027e57602002820191906000526020600020905b81548152602001906001019080831161026a575b50505050508152602001896009018054806020026020016040519081016040528092919081815260200182805480156102d657602002820191906000526020600020905b8154815260200190600101908083116102c2575b505050505081526020018860030180548060200260200160405190810160405280929190818152602001828054801561033857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161031a575b50505091835250506000602082018190526040820181905260608201819052608082015260a00161036889613417565b8152509050600060018260800151516103819190614d4f565b905060008260a00151518260ff166103999190614d62565b90508060ff168860ff161080156103b557508060ff168760ff16105b6104065760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064015b60405180910390fd5b5087546001600160a01b031660ff808316908916101561046057896007018860ff168154811061043857610438614d75565b6000918252602090912001546001600160a01b031660c084015260ff881660e08401526104a5565b60a083015161046f838a614da4565b60ff168151811061048257610482614d75565b60209081029190910101516001600160a01b031660c084015260ff821660e08401525b8160ff168760ff1610156104f557896007018760ff16815481106104cb576104cb614d75565b6000918252602090912001546001600160a01b031661010084015260ff871661012084015261053c565b60a08301516105048389614da4565b60ff168151811061051757610517614d75565b60209081029190910101516001600160a01b031661010084015260ff82166101208401525b60c08301516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561059f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c39190614dbd565b602084015260c08301516105e2906001600160a01b03163330896134dd565b602083015160c08401516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561064a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066e9190614dbd565b6106789190614d4f565b602084015260ff808316908916108061069657508160ff168760ff16105b15610ce85760006106b5846080015185606001518661014001516135b2565b90508260ff168960ff16101561071f5783606001518960ff16815181106106de576106de614d75565b6020026020010151876106f19190614dd6565b818a60ff168151811061070657610706614d75565b60200260200101516107189190614d62565b8452610881565b60008460a001515167ffffffffffffffff81111561073f5761073f614ab4565b604051908082528060200260200182016040528015610768578160200160208202803683370190505b5060208601519091508161077c868d614da4565b60ff168151811061078f5761078f614d75565b60209081029190910101526040517f4d49e87d0000000000000000000000000000000000000000000000000000000081526001600160a01b03841690634d49e87d906107e49084906000904290600401614e28565b6020604051808303816000875af1158015610803573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108279190614dbd565b60208601528151829060ff861690811061084357610843614d75565b6020026020010151670de0b6b3a764000086610140015187602001516108699190614dd6565b6108739190614e4d565b61087d9190614d62565b8552505b6000806108a36108908e613634565b60e08801516101208901518951876136db565b90506001818488610120015160ff16815181106108c2576108c2614d75565b60200260200101516108d49190614d4f565b6108de9190614d4f565b604087015260ff808616908b161061091e57856101400151670de0b6b3a7640000876040015161090e9190614dd6565b6109189190614e4d565b60408701525b6402540be4008d6004015487604001516109389190614dd6565b6109429190614e4d565b9150856060015186610120015160ff168151811061096257610962614d75565b602002602001015182876040015161097a9190614d4f565b6109849190614e4d565b60408701525060058c01546000906402540be400906109a39084614dd6565b6109ad9190614e4d565b9050856060015186610120015160ff16815181106109cd576109cd614d75565b6020026020010151816109e09190614e4d565b9050856020015186608001518760e0015160ff1681518110610a0457610a04614d75565b6020026020010151610a169190614d62565b8d6009018760e0015160ff1681548110610a3257610a32614d75565b9060005260206000200181905550808660400151876080015188610120015160ff1681518110610a6457610a64614d75565b6020026020010151610a769190614d4f565b610a809190614d4f565b8d60090187610120015160ff1681548110610a9d57610a9d614d75565b9060005260206000200181905550508360ff168960ff1610610c8d576101008501516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610b1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b429190614dbd565b9050836001600160a01b0316633e3a15608760400151878d610b649190614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152600060448201524260648201526084016020604051808303816000875af1158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190614dbd565b506101008601516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c9190614dbd565b610c869190614d4f565b6040870152505b8685604001511015610ce15760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e7360448201526064016103fd565b5050610ed2565b6101008301516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610d4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d709190614dbd565b60408401526001600160a01b0381166391695586610d8e848b614da4565b610d98858b614da4565b60208701516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b16815260ff938416600482015292909116602483015260448201526064810188905242608482015260a4016020604051808303816000875af1158015610e10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e349190614dbd565b5060408084015161010085015191517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290916001600160a01b0316906370a0823190602401602060405180830381865afa158015610e9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec29190614dbd565b610ecc9190614d4f565b60408401525b610ef93384604001518561010001516001600160a01b03166139629092919063ffffffff16565b6040838101518151888152602081019190915260ff8a81168284015289166060820152905133917f6617207207e397b41fc98016d8c9febb7223f44c355db66ad429730f2b950a60919081900360800190a2505060400151979650505050505050565b6000610f7386858585610f6e8a6139b0565b613a51565b509695505050505050565b60008085600701805480602002602001604051908101604052809291908181526020018280548015610fd957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fbb575b5050505050905080518451146110315760405162461bcd60e51b815260206004820181905260248201527f416d6f756e7473206d757374206d6174636820706f6f6c656420746f6b656e7360448201526064016103fd565b6000815167ffffffffffffffff81111561104d5761104d614ab4565b604051908082528060200260200182016040528015611076578160200160208202803683370190505b50604080516101208101825260008082526020820181905291810182905260068a01546001600160a01b03166060820152608081018290529192509060a081016110bf8a613634565b81526020016110cd89613417565b81526020018960080180548060200260200160405190810160405280929190818152602001828054801561112057602002820191906000526020600020905b81548152602001906001019080831161110c575b505050505081526020018960090180548060200260200160405190810160405280929190818152602001828054801561117857602002820191906000526020600020905b815481526020019060010190808311611164575b5050505050815250905080606001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e89190614dbd565b608082018190521561121c5761121961120f8261010001518360e001518460c001516135b2565b8260a00151613c41565b81525b60005b83518110156114f65760808201511515806112535750600087828151811061124957611249614d75565b6020026020010151115b61129f5760405162461bcd60e51b815260206004820152601e60248201527f4d75737420737570706c7920616c6c20746f6b656e7320696e20706f6f6c000060448201526064016103fd565b8681815181106112b1576112b1614d75565b602002602001015160001461147f5760008482815181106112d4576112d4614d75565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561133d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113619190614dbd565b90506113b533308a858151811061137a5761137a614d75565b602002602001015188868151811061139457611394614d75565b60200260200101516001600160a01b03166134dd909392919063ffffffff16565b808583815181106113c8576113c8614d75565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190614dbd565b61145f9190614d4f565b88838151811061147157611471614d75565b602002602001018181525050505b86818151811061149157611491614d75565b602002602001015182610100015182815181106114b0576114b0614d75565b60200260200101516114c29190614d62565b82610100015182815181106114d9576114d9614d75565b6020908102919091010152806114ee81614e88565b91505061121f565b5061151261120f8261010001518360e001518460c001516135b2565b602082018190528151106115685760405162461bcd60e51b815260206004820152601160248201527f442073686f756c6420696e63726561736500000000000000000000000000000060448201526064016103fd565b602081015160408201526080810151600090156117a35760006115908a600401548651613e16565b905060005b855181101561174657600084600001518c60090183815481106115ba576115ba614d75565b906000526020600020015486602001516115d49190614dd6565b6115de9190614e4d565b90506402540be400611617866101000151848151811061160057611600614d75565b602002602001015183613e4290919063ffffffff16565b6116219085614dd6565b61162b9190614e4d565b86838151811061163d5761163d614d75565b6020026020010181815250506402540be4008c6005015487848151811061166657611666614d75565b60200260200101516116789190614dd6565b6116829190614e4d565b856101000151838151811061169957611699614d75565b60200260200101516116ab9190614d4f565b8c60090183815481106116c0576116c0614d75565b90600052602060002001819055508582815181106116e0576116e0614d75565b602002602001015185610100015183815181106116ff576116ff614d75565b60200260200101516117119190614d4f565b856101000151838151811061172857611728614d75565b6020908102919091010152508061173e81614e88565b915050611595565b5061176c6117628461010001518560e001518660c001516135b2565b8460a00151613c41565b60408401819052835160808501519091611787908390614d4f565b6117919190614dd6565b61179b9190614e4d565b9150506117c7565b61010082015180516117bf9160098c019160209091019061499d565b505060208101515b858110156118175760405162461bcd60e51b815260206004820152601b60248201527f436f756c646e2774206d696e74206d696e20726571756573746564000000000060448201526064016103fd565b60068901546040517f40c10f19000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b15801561187e57600080fd5b505af1158015611892573d6000803e3d6000fd5b50505050336001600160a01b03167f189c623b666b1b45b83d7178f39b8c087cb09774317ca2f53c2d3c3726f222a2888585602001518587608001516118d89190614d62565b6040516118e89493929190614ec0565b60405180910390a293505050505b949350505050565b6000806119c96119bb8560090180548060200260200160405190810160405280929190818152602001828054801561195557602002820191906000526020600020905b815481526020019060010190808311611941575b5050505050866008018054806020026020016040519081016040528092919081815260200182805480156119a857602002820191906000526020600020905b815481526020019060010190808311611994575b50505050506119b6876139b0565b6135b2565b6119c486613634565b613c41565b905060008460060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a469190614dbd565b90508015611a745780611a61670de0b6b3a764000084614dd6565b611a6b9190614e4d565b92505050611a7b565b6000925050505b92915050565b6000611b10858484611a92886139b0565b8960060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0b9190614dbd565b613e67565b5095945050505050565b6000806040518060e00160405280611b31886139b0565b815287546001600160a01b03166020820152600060408201819052600389015460ff1660608301526080820181905260a0820181905260c0909101819052815191925090611b80908990613ede565b905060018151611b909190614d4f565b60ff16604083018190526060830151600091611bac9190614ef9565b90508060ff168760ff16108015611bc857508060ff168660ff16105b611c145760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b50816040015160ff168660ff161015611c8657876008018660ff1681548110611c3f57611c3f614d75565b906000526020600020015484611c559190614dd6565b818760ff1681518110611c6a57611c6a614d75565b6020026020010151611c7c9190614d62565b60a0830152611ef7565b6040820151611c959087614da4565b9550816040015160ff168560ff161015611e3a576000826060015160ff1667ffffffffffffffff811115611ccb57611ccb614ab4565b604051908082528060200260200182016040528015611cf4578160200160208202803683370190505b50905084818860ff1681518110611d0d57611d0d614d75565b602002602001018181525050670de0b6b3a7640000836000015184602001516001600160a01b031663e6ab28068460016040518363ffffffff1660e01b8152600401611d5a929190614f12565b602060405180830381865afa158015611d77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9b9190614dbd565b611da59190614dd6565b611daf9190614e4d565b60a084015260408301518251839160ff16908110611dcf57611dcf614d75565b60200260200101516402540be4006002611de99190614dd6565b8954611dfd906001600160a01b0316613f8f565b8560a00151611e0c9190614dd6565b611e169190614e4d565b8460a00151611e259190614d4f565b611e2f9190614d62565b60a084015250611eef565b81602001516001600160a01b031663a95b089f87846040015188611e5e9190614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260ff92831660048201529116602482015260448101879052606401602060405180830381865afa158015611ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee69190614dbd565b925050506120e0565b816040015195505b604082015160ff908116608084018190529086161015611f1b5760ff851660808301525b6000611f3a611f298a613634565b8885608001518660a00151866136db565b905060018183856080015160ff1681518110611f5857611f58614d75565b6020026020010151611f6a9190614d4f565b611f749190614d4f565b60c0840181905260048a01546000916402540be40091611f9391614dd6565b611f9d9190614e4d565b9050808460c00151611faf9190614d4f565b60c08501525050604082015160ff90811690861610156120095787600801826080015160ff1681548110611fe557611fe5614d75565b90600052602060002001548260c00151611fff9190614e4d565b60c08301526120d8565b81602001516001600160a01b031663342a87a18360000151670de0b6b3a76400008560c001516120399190614dd6565b6120439190614e4d565b60408501516120529089614da4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925260ff166024820152604401602060405180830381865afa1580156120ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d29190614dbd565b60c08301525b5060c0015190505b95945050505050565b600786015460009060ff8616811180156121055750808560ff16105b6121515760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20696e646578206973206f7574206f662072616e6765000000000060448201526064016103fd565b50600080886007018760ff168154811061216d5761216d614d75565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116915081906370a0823190602401602060405180830381865afa1580156121da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fe9190614dbd565b85111561224d5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073776170206d6f7265207468616e20796f75206f776e00000060448201526064016103fd565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156122ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d19190614dbd565b90506122e86001600160a01b0383163330896134dd565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015612347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236b9190614dbd565b6123759190614d4f565b9250505060008061238c8a898986610f6e8e613417565b91509150848210156123e05760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e7360448201526064016103fd565b60008a6008018860ff16815481106123fa576123fa614d75565b90600052602060002001546402540be4008c600501548461241b9190614dd6565b6124259190614e4d565b61242f9190614e4d565b9050838b6009018a60ff168154811061244a5761244a614d75565b906000526020600020015461245f9190614d62565b8b6009018a60ff168154811061247757612477614d75565b906000526020600020018190555080838c6009018a60ff168154811061249f5761249f614d75565b90600052602060002001546124b49190614d4f565b6124be9190614d4f565b8b6009018960ff16815481106124d6576124d6614d75565b906000526020600020018190555061251d33848d6007018b60ff168154811061250157612501614d75565b6000918252602090912001546001600160a01b03169190613962565b604080518581526020810185905260ff8b8116828401528a166060820152905133917fc6c1e0630dbe9130cc068028486c0d118ddcea348550819defd5cb8c257f8a38919081900360800190a250909998505050505050505050565b6006850154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691839183916318160ddd9160048083019260209291908290030181865afa1580156125e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126069190614dbd565b60078901546040517f70a08231000000000000000000000000000000000000000000000000000000008152336004820152919250906001600160a01b038416906370a0823190602401602060405180830381865afa15801561266c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126909190614dbd565b8711156126df5760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f660000000000000000000000000000000000000060448201526064016103fd565b808660ff16106127315760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e64000000000000000000000000000000000060448201526064016103fd565b6000806127498b8a8a6127438e613417565b88613e67565b925090508681101561279d5760405162461bcd60e51b815260206004820152600e60248201527f6479203c206d696e416d6f756e7400000000000000000000000000000000000060448201526064016103fd565b6402540be4008b60050154836127b39190614dd6565b6127bd9190614e4d565b6127c79082614d62565b8b6009018960ff16815481106127df576127df614d75565b90600052602060002001546127f49190614d4f565b8b6009018960ff168154811061280c5761280c614d75565b6000918252602090912001556040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b15801561287957600080fd5b505af115801561288d573d6000803e3d6000fd5b505050506128ae33828d6007018b60ff168154811061250157612501614d75565b604080518a81526020810186905260ff8a168183015260608101839052905133917f43fb02998f4e03da2e0e6fff53fdbf0c40a9f45f145dc377fc30615d7d7a8a64919081900360800190a29a9950505050505050505050565b604080516101208101825260008082526020820181905291810182905260068601546001600160a01b0316606082015260808101829052819060a0810161294e88613634565b815260200161295c87613417565b8152602001876008018054806020026020016040519081016040528092919081815260200182805480156129af57602002820191906000526020600020905b81548152602001906001019080831161299b575b5050505050815260200187600901805480602002602001604051908101604052809291908181526020018280548015612a0757602002820191906000526020600020905b8154815260200190600101908083116129f3575b5050505050815250905080606001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a779190614dbd565b608082015261010081015151845114612ad25760405162461bcd60e51b815260206004820181905260248201527f416d6f756e74732073686f756c64206d6174636820706f6f6c20746f6b656e7360448201526064016103fd565b82600003612b225760405162461bcd60e51b815260206004820152601560248201527f4d757374206275726e206d6f7265207468616e2030000000000000000000000060448201526064016103fd565b6000612b38876004015483610100015151613e16565b905060008261010001515167ffffffffffffffff811115612b5b57612b5b614ab4565b604051908082528060200260200182016040528015612b84578160200160208202803683370190505b50905060008361010001515167ffffffffffffffff811115612ba857612ba8614ab4565b604051908082528060200260200182016040528015612bd1578160200160208202803683370190505b509050612bf9612bef8561010001518660e001518760c001516135b2565b8560a00151613c41565b845260005b84610100015151811015612d23578461010001518181518110612c2357612c23614d75565b6020026020010151888281518110612c3d57612c3d614d75565b60200260200101511115612cb95760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c65000000000000000000000000000000000000000000000000000000000060648201526084016103fd565b878181518110612ccb57612ccb614d75565b60200260200101518561010001518281518110612cea57612cea614d75565b602002602001015103828281518110612d0557612d05614d75565b60200260200101818152505080612d1b81614e88565b915050612bfe565b50612d3a612bef828660e001518760c001516135b2565b602085015260005b84610100015151811015612ed357600085600001518661010001518381518110612d6e57612d6e614d75565b60200260200101518760200151612d859190614dd6565b612d8f9190614e4d565b90506000612da884848151811061160057611600614d75565b90506402540be400612dba8288614dd6565b612dc49190614e4d565b858481518110612dd657612dd6614d75565b6020026020010181815250506402540be4008c60050154868581518110612dff57612dff614d75565b6020026020010151612e119190614dd6565b612e1b9190614e4d565b848481518110612e2d57612e2d614d75565b6020026020010151612e3f9190614d4f565b8c6009018481548110612e5457612e54614d75565b9060005260206000200181905550848381518110612e7457612e74614d75565b6020026020010151848481518110612e8e57612e8e614d75565b6020026020010151612ea09190614d4f565b848481518110612eb257612eb2614d75565b60200260200101818152505050508080612ecb90614e88565b915050612d42565b50612eea612bef828660e001518760c001516135b2565b6040850181905284516080860151600093509091612f089083614d4f565b612f129190614dd6565b612f1c9190614e4d565b905080600003612f6e5760405162461bcd60e51b815260206004820152601b60248201527f4275726e7420616d6f756e742063616e6e6f74206265207a65726f000000000060448201526064016103fd565b612f79816001614d62565b905085811115612fcb5760405162461bcd60e51b815260206004820152601b60248201527f746f6b656e416d6f756e74203e206d61784275726e416d6f756e74000000000060448201526064016103fd565b60608401516040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561303257600080fd5b505af1158015613046573d6000803e3d6000fd5b5050505060005b846101000151518110156130a05761308e3389838151811061307157613071614d75565b60200260200101518c600701848154811061250157612501614d75565b8061309881614e88565b91505061304d565b50336001600160a01b03167f3631c28b1f9dd213e0319fb167b554d76b6c283a41143eb400a0d1adb1af1755888487602001518589608001516118d89190614d4f565b6000806130ef87613634565b905060008060006130ff896139b0565b905060008a60090180548060200260200160405190810160405280929190818152602001828054801561315157602002820191906000526020600020905b81548152602001906001019080831161313d575b5050505050905060008b6008018054806020026020016040519081016040528092919081815260200182805480156131a857602002820191906000526020600020905b815481526020019060010190808311613194575b505050505090506000825190506131c96131c38484876135b2565b88613c41565b955060005b8181101561334857891561323c578b8b828181106131ee576131ee614d75565b9050602002013584828151811061320757613207614d75565b60200260200101516132199190614d62565b84828151811061322b5761322b614d75565b602002602001018181525050613336565b83818151811061324e5761324e614d75565b60200260200101518c8c8381811061326857613268614d75565b9050602002013511156132e35760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c65000000000000000000000000000000000000000000000000000000000060648201526084016103fd565b8b8b828181106132f5576132f5614d75565b9050602002013584828151811061330e5761330e614d75565b60200260200101510384828151811061332957613329614d75565b6020026020010181815250505b8061334081614e88565b9150506131ce565b506133576131c38484876135b2565b94505050505060008960060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d89190614dbd565b9050851561340b5782816133ec8285614d4f565b6133f69190614dd6565b6134009190614e4d565b9450505050506120e0565b82816133ec8483614d4f565b6000610258826002015461342b9190614d62565b4211156134d0578154604080517fe25aa5fa00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163e25aa5fa9160048083019260209291908290030181865afa158015613494573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134b89190614dbd565b60018401819055426002909401939093555090919050565b506001015490565b919050565b6040516001600160a01b03808516602483015283166044820152606481018290526135ac9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614000565b50505050565b606060006135c085856140e5565b90506000600186516135d29190614d4f565b9050670de0b6b3a7640000848383815181106135f0576135f0614d75565b60200260200101516136029190614dd6565b61360c9190614e4d565b82828151811061361e5761361e614d75565b60209081029190910101525090505b9392505050565b60038101546001820154600091904282111561362d57600284015484548083111561369f576136638285614d4f565b61366d8342614d4f565b6136778386614d4f565b6136819190614dd6565b61368b9190614e4d565b6136959082614d62565b9695505050505050565b6136a98285614d4f565b6136b38342614d4f565b6136bd8584614d4f565b6136c79190614dd6565b6136d19190614e4d565b6136959082614d4f565b805160009060ff808616908716036137355760405162461bcd60e51b815260206004820152601d60248201527f43616e277420636f6d7061726520746f6b656e20746f20697473656c6600000060448201526064016103fd565b808660ff161080156137495750808560ff16105b6137955760405162461bcd60e51b815260206004820152601660248201527f546f6b656e73206d75737420626520696e20706f6f6c0000000000000000000060448201526064016103fd565b60006137a18489613c41565b9050806000806137b18b86614dd6565b90506000805b86811015613840578b60ff1681036137d157899150613801565b8a60ff1681146137fc578881815181106137ed576137ed614d75565b60200260200101519150613801565b61382e565b61380b8285614d62565b93506138178783614dd6565b6138218787614dd6565b61382b9190614e4d565b94505b8061383881614e88565b9150506137b7565b5061384b8683614dd6565b60646138578787614dd6565b6138619190614dd6565b61386b9190614e4d565b935060008261387b606488614dd6565b6138859190614e4d565b61388f9085614d62565b9050600086815b6101008110156139195781925088848360026138b29190614dd6565b6138bc9190614d62565b6138c69190614d4f565b886138d18480614dd6565b6138db9190614d62565b6138e59190614e4d565b91506138f18284614203565b15613907575098506120e0975050505050505050565b8061391181614e88565b915050613896565b5060405162461bcd60e51b815260206004820152601e60248201527f417070726f78696d6174696f6e20646964206e6f7420636f6e7665726765000060448201526064016103fd565b6040516001600160a01b0383166024820152604481018290526139ab9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161352a565b505050565b600061025882600201546139c49190614d62565b4211156134d0578154604080517fe25aa5fa00000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163e25aa5fa916004808201926020929091908290030181865afa158015613a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7b9190614dbd565b6000806000613a608885613ede565b905080518760ff16108015613a78575080518660ff16105b613ac45760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b600060018251613ad49190614d4f565b90506000896008018960ff1681548110613af057613af0614d75565b906000526020600020015487613b069190614dd6565b9050818960ff1603613b3257670de0b6b3a7640000613b258783614dd6565b613b2f9190614e4d565b90505b828960ff1681518110613b4757613b47614d75565b602002602001015181613b5a9190614d62565b90506000613b73613b6a8c613634565b8b8b85886136db565b9050600181858b60ff1681518110613b8d57613b8d614d75565b6020026020010151613b9f9190614d4f565b613ba99190614d4f565b9550828960ff1603613bd55786613bc8670de0b6b3a764000088614dd6565b613bd29190614e4d565b95505b6402540be4008b6004015487613beb9190614dd6565b613bf59190614e4d565b9450613c018587614d4f565b95508a6008018960ff1681548110613c1b57613c1b614d75565b906000526020600020015486613c319190614e4d565b9550505050509550959350505050565b815160009081805b82811015613c8a57858181518110613c6357613c63614d75565b602002602001015182613c769190614d62565b915080613c8281614e88565b915050613c49565b5080600003613c9e57600092505050611a7b565b60008181613cac8588614dd6565b905060005b610100811015613dcd578260005b87811015613d1457878b8281518110613cda57613cda614d75565b6020026020010151613cec9190614dd6565b613cf68684614dd6565b613d009190614e4d565b915080613d0c81614e88565b915050613cbf565b5083945080876001613d269190614d62565b613d309190614dd6565b606485613d3d8287614d4f565b613d479190614dd6565b613d519190614e4d565b613d5b9190614d62565b84613d668984614dd6565b6064613d728a88614dd6565b613d7c9190614e4d565b613d869190614d62565b613d909190614dd6565b613d9a9190614e4d565b9350613da68486614203565b15613dba5783975050505050505050611a7b565b5080613dc581614e88565b915050613cb1565b5060405162461bcd60e51b815260206004820152601360248201527f4420646f6573206e6f7420636f6e76657267650000000000000000000000000060448201526064016103fd565b6000613e23600183614d4f565b613e2e906004614dd6565b613e388385614dd6565b61362d9190614e4d565b600081831115613e5d57613e568284614d4f565b9050611a7b565b61362d8383614d4f565b600080600080600080613e7d8b8a8c8b8b61421a565b60088e018054939750909450909250859160ff8c16908110613ea157613ea1614d75565b90600052602060002001548284613eb89190614d4f565b613ec29190614e4d565b613ecc9190614d4f565b939b939a509298505050505050505050565b606061362d83600901805480602002602001604051908101604052809291908181526020018280548015613f3157602002820191906000526020600020905b815481526020019060010190808311613f1d575b505050505084600801805480602002602001604051908101604052809291908181526020018280548015613f8457602002820191906000526020600020905b815481526020019060010190808311613f70575b5050505050846135b2565b6000816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e060405180830381865afa158015613fcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ff39190614f36565b5090979650505050505050565b6000614055826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166146459092919063ffffffff16565b8051909150156139ab57808060200190518101906140739190614fa2565b6139ab5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016103fd565b8151815160609190811461413b5760405162461bcd60e51b815260206004820152601f60248201527f42616c616e636573206d757374206d61746368206d756c7469706c696572730060448201526064016103fd565b60008167ffffffffffffffff81111561415657614156614ab4565b60405190808252806020026020018201604052801561417f578160200160208202803683370190505b50905060005b828110156141fa5784818151811061419f5761419f614d75565b60200260200101518682815181106141b9576141b9614d75565b60200260200101516141cb9190614dd6565b8282815181106141dd576141dd614d75565b6020908102919091010152806141f281614e88565b915050614185565b50949350505050565b600060016142118484613e42565b11159392505050565b60008060008061422a8987613ede565b905080518860ff161061427f5760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e6765000000000000000060448201526064016103fd565b60006040518060c00160405280600081526020016000815260200160008152602001600081526020016142b18c613634565b8152602001600081525090506142cb828260800151613c41565b80825286906142da908a614dd6565b6142e49190614e4d565b81516142f09190614d4f565b60208201528151829060ff8b1690811061430c5761430c614d75565b60200260200101518811156143635760405162461bcd60e51b815260206004820152601a60248201527f5769746864726177206578636565647320617661696c61626c6500000000000060448201526064016103fd565b61437781608001518a848460200151614654565b6040820152815160009067ffffffffffffffff81111561439957614399614ab4565b6040519080825280602002602001820160405280156143c2578160200160208202803683370190505b5090506143d48b600401548451613e16565b606083015260005b83518110156144d2578381815181106143f7576143f7614d75565b60200260200101518360a00181815250506402540be40083606001518c60ff168314614451578451602086015160a08701516144339190614dd6565b61443d9190614e4d565b8560a0015161444c9190614d4f565b614480565b60408501518551602087015160a088015161446c9190614dd6565b6144769190614e4d565b6144809190614d4f565b61448a9190614dd6565b6144949190614e4d565b8360a001516144a39190614d4f565b8282815181106144b5576144b5614d75565b6020908102919091010152806144ca81614e88565b9150506143dc565b5060006144e983608001518c848660200151614654565b828c60ff16815181106144fe576144fe614d75565b60200260200101516145109190614d4f565b9050600184516145209190614d4f565b8b60ff16036145d1578861453c670de0b6b3a764000083614dd6565b6145469190614e4d565b905088670de0b6b3a764000084604001516145619190614dd6565b61456b9190614e4d565b83604001818152505088670de0b6b3a7640000858d60ff168151811061459357614593614d75565b60200260200101516145a59190614dd6565b6145af9190614e4d565b848c60ff16815181106145c4576145c4614d75565b6020026020010181815250505b8b6008018b60ff16815481106145e9576145e9614d75565b90600052602060002001546001826146019190614d4f565b61460b9190614e4d565b9050808360400151858d60ff168151811061462857614628614d75565b602002602001015196509650965050505050955095509592505050565b60606118f6848460008561481c565b815160009060ff851681116146ab5760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e64000000000000000000000000000000000060448201526064016103fd565b826000806146b9848a614dd6565b905060005b84811015614745578860ff168114614733578781815181106146e2576146e2614d75565b6020026020010151836146f59190614d62565b92508488828151811061470a5761470a614d75565b602002602001015161471c9190614dd6565b6147268886614dd6565b6147309190614e4d565b93505b8061473d81614e88565b9150506146be565b506147508482614dd6565b606461475c8886614dd6565b6147669190614dd6565b6147709190614e4d565b9250600081614780606489614dd6565b61478a9190614e4d565b6147949084614d62565b9050600087815b6101008110156139195781925089848360026147b79190614dd6565b6147c19190614d62565b6147cb9190614d4f565b876147d68480614dd6565b6147e09190614d62565b6147ea9190614e4d565b91506147f68284614203565b1561480a575096506118f695505050505050565b8061481481614e88565b91505061479b565b6060824710156148945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016103fd565b6001600160a01b0385163b6148eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103fd565b600080866001600160a01b031685876040516149079190614fe3565b60006040518083038185875af1925050503d8060008114614944576040519150601f19603f3d011682016040523d82523d6000602084013e614949565b606091505b5091509150614959828286614964565b979650505050505050565b6060831561497357508161362d565b8251156149835782518084602001fd5b8160405162461bcd60e51b81526004016103fd9190614fff565b8280548282559060005260206000209081019282156149d8579160200282015b828111156149d85782518255916020019190600101906149bd565b506149e49291506149e8565b5090565b5b808211156149e457600081556001016149e9565b803560ff811681146134d857600080fd5b60008060008060008060c08789031215614a2757600080fd5b8635955060208701359450614a3e604088016149fd565b9350614a4c606088016149fd565b92506080870135915060a087013590509295509295509295565b600080600080600060a08688031215614a7e57600080fd5b8535945060208601359350614a95604087016149fd565b9250614aa3606087016149fd565b949793965091946080013592915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060008060808587031215614af957600080fd5b843593506020808601359350604086013567ffffffffffffffff80821115614b2057600080fd5b818801915088601f830112614b3457600080fd5b813581811115614b4657614b46614ab4565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715614b8957614b89614ab4565b60405291825284820192508381018501918b831115614ba757600080fd5b938501935b82851015614bc557843584529385019392850192614bac565b989b979a509798606001359750505050505050565b60008060408385031215614bed57600080fd5b50508035926020909101359150565b60008060008060808587031215614c1257600080fd5b843593506020850135925060408501359150614c30606086016149fd565b905092959194509250565b600080600080600060a08688031215614c5357600080fd5b853594506020860135935060408601359250614aa3606087016149fd565b8015158114614c7f57600080fd5b50565b600080600080600060808688031215614c9a57600080fd5b8535945060208601359350604086013567ffffffffffffffff80821115614cc057600080fd5b818801915088601f830112614cd457600080fd5b813581811115614ce357600080fd5b8960208260051b8501011115614cf857600080fd5b6020830195508094505050506060860135614d1281614c71565b809150509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611a7b57611a7b614d20565b80820180821115611a7b57611a7b614d20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60ff8281168282160390811115611a7b57611a7b614d20565b600060208284031215614dcf57600080fd5b5051919050565b8082028115828204841417611a7b57611a7b614d20565b600081518084526020808501945080840160005b83811015614e1d57815187529582019590820190600101614e01565b509495945050505050565b606081526000614e3b6060830186614ded565b60208301949094525060400152919050565b600082614e83577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614eb957614eb9614d20565b5060010190565b608081526000614ed36080830187614ded565b8281036020840152614ee58187614ded565b604084019590955250506060015292915050565b60ff8181168382160190811115611a7b57611a7b614d20565b604081526000614f256040830185614ded565b905082151560208301529392505050565b600080600080600080600060e0888a031215614f5157600080fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c08801516001600160a01b0381168114614f9257600080fd5b8091505092959891949750929550565b600060208284031215614fb457600080fd5b815161362d81614c71565b60005b83811015614fda578181015183820152602001614fc2565b50506000910152565b60008251614ff5818460208701614fbf565b9190910192915050565b602081526000825180602084015261501e816040850160208701614fbf565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea26469706673582212209bc4c95d126ff94844fe591d872d4eed1e12df4f9a361a24eb726740e13d22b364736f6c63430008110033", + "devdoc": { + "details": "Contracts relying on this library must initialize SwapUtils.Swap struct then use this library for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins. Admin functions should be protected within contracts using this library.", + "kind": "dev", + "methods": { + "addLiquidity(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "metaSwapStorage": "MetaSwap struct to read from and write to", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.", + "self": "Swap struct to read from and write to" + }, + "returns": { + "_0": "amount of LP token user received" + } + }, + "calculateSwap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)": { + "params": { + "dx": "the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "metaSwapStorage": "MetaSwap struct from the same contract", + "self": "Swap struct to read from", + "tokenIndexFrom": "the token to sell", + "tokenIndexTo": "the token to buy" + }, + "returns": { + "dy": "the number of tokens the user will get" + } + }, + "calculateSwapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)": { + "params": { + "dx": "the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "metaSwapStorage": "MetaSwap struct from the same contract", + "self": "Swap struct to read from", + "tokenIndexFrom": "the token to sell", + "tokenIndexTo": "the token to buy" + }, + "returns": { + "_0": "dy the number of tokens the user will get" + } + }, + "calculateTokenAmount(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal", + "metaSwapStorage": "MetaSwap struct to read from", + "self": "Swap struct to read from" + }, + "returns": { + "_0": "if deposit was true, total amount of lp token that will be minted and if deposit was false, total amount of lp token that will be burned" + } + }, + "calculateWithdrawOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8)": { + "params": { + "metaSwapStorage": "MetaSwap struct to read from", + "self": "Swap struct to read from", + "tokenAmount": "the amount to withdraw in the pool's precision", + "tokenIndex": "which token will be withdrawn" + }, + "returns": { + "dy": "the amount of token user will receive" + } + }, + "getVirtualPrice(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage)": { + "params": { + "metaSwapStorage": "MetaSwap struct to read from", + "self": "Swap struct to read from" + }, + "returns": { + "_0": "the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION" + } + }, + "removeLiquidityImbalance(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.", + "metaSwapStorage": "MetaSwap struct to read from and write to", + "self": "Swap struct to read from and write to" + }, + "returns": { + "_0": "actual amount of LP tokens burned in the withdrawal" + } + }, + "removeLiquidityOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8,uint256)": { + "params": { + "metaSwapStorage": "MetaSwap struct to read from and write to", + "minAmount": "the minimum amount to withdraw, otherwise revert", + "self": "Swap struct to read from and write to", + "tokenAmount": "the amount of the lp tokens to burn", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount chosen token that user received" + } + }, + "swap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell", + "metaSwapStorage": "MetaSwap struct to read from and write to", + "minDy": "the min amount the user would like to receive, or revert.", + "self": "Swap struct to read from and write to", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of token user received on swap" + } + }, + "swapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)": { + "details": "Since this calls multiple external functions during the execution, it is recommended to protect any function that depends on this with reentrancy guards.", + "params": { + "dx": "the amount of tokens the user wants to sell", + "metaSwapStorage": "MetaSwap struct to read from and write to", + "minDy": "the min amount the user would like to receive, or revert.", + "self": "Swap struct to read from and write to", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of token user received on swap" + } + } + }, + "title": "MetaSwapUtils library", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)": { + "notice": "Add liquidity to the pool" + }, + "calculateSwap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)": { + "notice": "Externally calculates a swap between two tokens. The SwapUtils.Swap storage and MetaSwap storage should be from the same MetaSwap contract." + }, + "calculateSwapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256)": { + "notice": "Calculates the expected return amount from swapping between the pooled tokens and the underlying tokens of the base Swap pool." + }, + "calculateTokenAmount(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running" + }, + "calculateWithdrawOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8)": { + "notice": "Calculate how much the user would receive when withdrawing via single token" + }, + "getVirtualPrice(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage)": { + "notice": "Get the virtual price, to help calculate profit" + }, + "removeLiquidityImbalance(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256[],uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances." + }, + "removeLiquidityOneToken(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint256,uint8,uint256)": { + "notice": "Remove liquidity from the pool all in one token." + }, + "swap(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)": { + "notice": "swap two tokens in the pool" + }, + "swapUnderlying(SwapUtilsV2.Swap storage,MetaSwapUtilsV1.MetaSwap storage,uint8,uint8,uint256,uint256)": { + "notice": "Swaps with the underlying tokens of the base Swap pool. For this function, the token indices are flattened out so that underlying tokens are represented in the indices." + } + }, + "notice": "A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities. MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens. As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/base_testnet/Multicall3.json b/deployments/base_testnet/Multicall3.json new file mode 100644 index 00000000..ae9af721 --- /dev/null +++ b/deployments/base_testnet/Multicall3.json @@ -0,0 +1,443 @@ +{ + "address": "0xcA11bde05977b3631167028862bE2a173976CA11", + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "returnData", + "type": "bytes[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowFailure", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call3[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate3", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowFailure", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call3Value[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate3Value", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "blockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getBasefee", + "outputs": [ + { + "internalType": "uint256", + "name": "basefee", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBlockNumber", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "chainid", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockCoinbase", + "outputs": [ + { + "internalType": "address", + "name": "coinbase", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockDifficulty", + "outputs": [ + { + "internalType": "uint256", + "name": "difficulty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "gaslimit", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getEthBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryAggregate", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "requireSuccess", + "type": "bool" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "tryBlockAndAggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "internalType": "struct Multicall3.Result[]", + "name": "returnData", + "type": "tuple[]" + } + ], + "stateMutability": "payable", + "type": "function" + } + ] +} diff --git a/deployments/base_testnet/PermissionlessDeployer.json b/deployments/base_testnet/PermissionlessDeployer.json new file mode 100644 index 00000000..9aeb7b48 --- /dev/null +++ b/deployments/base_testnet/PermissionlessDeployer.json @@ -0,0 +1,1088 @@ +{ + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "internalType": "address", + "name": "_masterRegistry", + "type": "address" + }, + { + "internalType": "address", + "name": "_targetLPToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_targetSwap", + "type": "address" + }, + { + "internalType": "address", + "name": "_targetMetaSwap", + "type": "address" + }, + { + "internalType": "address", + "name": "_targetMetaSwapDeposit", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "cloneAddress", + "type": "address" + } + ], + "name": "NewClone", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "deployer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "swapAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "pooledTokens", + "type": "address[]" + } + ], + "name": "NewSwapPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "poolRegistry", + "type": "address" + } + ], + "name": "PoolRegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "TargetLPTokenUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "TargetMetaSwapDepositUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "TargetMetaSwapUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "TargetSwapUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LP_TOKEN_NAME0", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LP_TOKEN_NAME1", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MASTER_REGISTRY", + "outputs": [ + { + "internalType": "contract IMasterRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL_REGISTRY_NAME", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SADDLE_MANAGER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "clone", + "outputs": [ + { + "internalType": "address", + "name": "newClone", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "baseSwap", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + } + ], + "internalType": "struct PermissionlessDeployer.DeployMetaSwapInput", + "name": "input", + "type": "tuple" + } + ], + "name": "deployMetaSwap", + "outputs": [ + { + "internalType": "address", + "name": "deployedMetaSwap", + "type": "address" + }, + { + "internalType": "address", + "name": "deployedMetaSwapDeposit", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + } + ], + "internalType": "struct PermissionlessDeployer.DeploySwapInput", + "name": "input", + "type": "tuple" + } + ], + "name": "deploySwap", + "outputs": [ + { + "internalType": "address", + "name": "deployedSwap", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolRegistryCached", + "outputs": [ + { + "internalType": "contract IPoolRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_targetLPToken", + "type": "address" + } + ], + "name": "setTargetLPToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_targetMetaSwap", + "type": "address" + } + ], + "name": "setTargetMetaSwap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_targetMetaSwapDeposit", + "type": "address" + } + ], + "name": "setTargetMetaSwapDeposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_targetSwap", + "type": "address" + } + ], + "name": "setTargetSwap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "targetLPToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "targetMetaSwap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "targetMetaSwapDeposit", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "targetSwap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "updatePoolRegistryCache", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "transactionIndex": 1, + "gasUsed": "2490754", + "logsBloom": "0x00000004000400000000400000000000000000000000480000000040000000040000000000000000000020000000002100004000040000000000000000000000000000000000000000000000200000000000000000040000000000000000001000000000020000100000000001000800800000000000000000000000000000800200000000000000004000000000000420100000000000000000000000000020800000040000000000000000000000000000000004000000001000000000000000000020000000000000000000000000000002000200000100000000000020000080000000000000000000000000000000000000000080000000000000000000", + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c", + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + }, + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0xe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + }, + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x336ea638298c0cea1e72c71ed04716bef23a7a6251478299d7ca4067fea0c479", + "0x000000000000000000000000db5c5a6162115ce9a188e7d773c4d011f421bbe5" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + }, + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x6c149d1850b03102a8ac77fc865c12f017f4fb8bf9f9af345d36b0e8b60bcc85", + "0x000000000000000000000000dca5b16a96f984ffb2a3022cff339eb049126101" + ], + "data": "0x", + "logIndex": 3, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + }, + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x06fc5602fc767cbb172d176a4cd0531d747abbdd090065ebd7b63ee4d2f0b44d", + "0x000000000000000000000000e280efe654328a3325fc5a9eab8e998d418c86fb" + ], + "data": "0x", + "logIndex": 4, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + }, + { + "transactionIndex": 1, + "blockNumber": 2717075, + "transactionHash": "0x91ce11c534843a6eb6d0473e1259ba281fb5e61dd7e0e7a97275f187618675a1", + "address": "0x4E1484607760118ebE2Ab07C0c71f1B4D9671e01", + "topics": [ + "0x768ccdac0361ba56b697aa598fdd415f51a59d121b9d2b50714d3072cc4a8f17", + "0x0000000000000000000000005dd186f8809147f96d3ffc4508f3c82694e58c9c" + ], + "data": "0x", + "logIndex": 5, + "blockHash": "0xb125d8700d66f93eaa54a7696811e5e965a955ecbdf73aaaa95a7340c813a28c" + } + ], + "blockNumber": 2717075, + "cumulativeGasUsed": "2490754", + "status": 1, + "byzantium": true + }, + "args": [ + "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "0x9cDeF6e33687F438808766fC133b2E9d1A16AD57", + "0xdb5c5A6162115Ce9a188E7D773C4D011F421BbE5", + "0xDCA5b16A96f984ffb2A3022cfF339eb049126101", + "0xe280EFE654328a3325fc5A9EAb8E998D418C86FB", + "0x5dD186f8809147F96D3ffC4508F3C82694E58c9c" + ], + "numDeployments": 1, + "solcInputHash": "bc3a64a5cffb1e8de0dbf9fb306e4f9f", + "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_masterRegistry\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_targetLPToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_targetSwap\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_targetMetaSwap\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_targetMetaSwapDeposit\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cloneAddress\",\"type\":\"address\"}],\"name\":\"NewClone\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"deployer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"swapAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"contract IERC20[]\",\"name\":\"pooledTokens\",\"type\":\"address[]\"}],\"name\":\"NewSwapPool\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolRegistry\",\"type\":\"address\"}],\"name\":\"PoolRegistryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"TargetLPTokenUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"TargetMetaSwapDepositUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"TargetMetaSwapUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"TargetSwapUpdated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"LP_TOKEN_NAME0\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"LP_TOKEN_NAME1\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MASTER_REGISTRY\",\"outputs\":[{\"internalType\":\"contract IMasterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"POOL_REGISTRY_NAME\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SADDLE_MANAGER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"clone\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"newClone\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"baseSwap\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"}],\"internalType\":\"struct PermissionlessDeployer.DeployMetaSwapInput\",\"name\":\"input\",\"type\":\"tuple\"}],\"name\":\"deployMetaSwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"deployedMetaSwap\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"deployedMetaSwapDeposit\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"}],\"internalType\":\"struct PermissionlessDeployer.DeploySwapInput\",\"name\":\"input\",\"type\":\"tuple\"}],\"name\":\"deploySwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"deployedSwap\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"poolRegistryCached\",\"outputs\":[{\"internalType\":\"contract IPoolRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_targetLPToken\",\"type\":\"address\"}],\"name\":\"setTargetLPToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_targetMetaSwap\",\"type\":\"address\"}],\"name\":\"setTargetMetaSwap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_targetMetaSwapDeposit\",\"type\":\"address\"}],\"name\":\"setTargetMetaSwapDeposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_targetSwap\",\"type\":\"address\"}],\"name\":\"setTargetSwap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"targetLPToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"targetMetaSwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"targetMetaSwapDeposit\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"targetSwap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updatePoolRegistryCache\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"NewSwapPool(address,address,address[])\":{\"params\":{\"deployer\":\"address of the deployer\",\"pooledTokens\":\", array of addresses of the tokens in the pool\",\"swapAddress\":\"address of the deployed pool\"}},\"PoolRegistryUpdated(address)\":{\"params\":{\"poolRegistry\":\"address of the current Saddle Pool Registry\"}}},\"kind\":\"dev\",\"methods\":{\"clone(address)\":{\"params\":{\"target\":\"the address of the target pool to be cloned\"},\"returns\":{\"newClone\":\"an address of the cloned pool\"}},\"deployMetaSwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,address,uint8))\":{\"params\":{\"input\":\", a DeployMetaSwapInput struct containing the input parameters for the meta pool.\"}},\"deploySwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,uint8))\":{\"params\":{\"input\":\", a struct containing the input parameters for the pool to be deployed, must include a unique pool name.\"},\"returns\":{\"deployedSwap\":\"the address of the deployed pool.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"title\":\"PermissionlessDeployer\",\"version\":1},\"userdoc\":{\"events\":{\"NewSwapPool(address,address,address[])\":{\"notice\":\"Emmited when a new pool is deployed\"},\"PoolRegistryUpdated(address)\":{\"notice\":\"Emmited when the pool registry cache is updated\"}},\"kind\":\"user\",\"methods\":{\"SADDLE_MANAGER_ROLE()\":{\"notice\":\"Role responsible for managing target addresses\"},\"clone(address)\":{\"notice\":\"Uses openzeppelin's clone mechanism to clone an existing a pool for cheaper deployments.\"},\"deployMetaSwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,address,uint8))\":{\"notice\":\"Deploys a new meta pool.\"},\"deploySwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,uint8))\":{\"notice\":\"Deploys a new pool, adds an entry in the Saddle Pool Registry.\"},\"updatePoolRegistryCache()\":{\"notice\":\"Updates cached address of the pool registry **should be onlymanager?\"}},\"notice\":\"Allows for anyone to indepentantly deploy pools and meta pools of given tokens. A user will set custom parameters for the pool such as the trading/admin fees, as well as the a-parameter. Ownership of the pools are given to the deploying address. Saddle will collect 50% of the trading fees earned by the pool.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/permissionless/PermissionlessDeployer.sol\":\"PermissionlessDeployer\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/EnumerableSet.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using Address for address;\\n\\n struct RoleData {\\n EnumerableSet.AddressSet members;\\n bytes32 adminRole;\\n }\\n\\n mapping (bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view returns (bool) {\\n return _roles[role].members.contains(account);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\\n return _roles[role].members.length();\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\\n return _roles[role].members.at(index);\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to grant\\\");\\n\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to revoke\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\\n _roles[role].adminRole = adminRole;\\n }\\n\\n function _grantRole(bytes32 role, address account) private {\\n if (_roles[role].members.add(account)) {\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n function _revokeRole(bytes32 role, address account) private {\\n if (_roles[role].members.remove(account)) {\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc155a2f7837603d69a13cfa481eb5e7f5e02cb77e2ec9edbac30986db37988\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\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 () internal {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n}\\n\",\"keccak256\":\"0x15e2d5bd4c28a88548074c54d220e8086f638a71ed07e6b3ba5a70066fcf458d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xcc78a17dd88fa5a2edc60c8489e2f405c0913b377216a5b26b35656b2d0dab52\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address master) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `master` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\\n return predictDeterministicAddress(master, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0x0d24348f536f928d8b42789737bf34762faee065667ab530ea20969a9d9920d1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) public {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0xca0c2396dbeb3503b51abf4248ebf77a1461edad513c01529df51850a012bee3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x1562cd9922fbf739edfb979f506809e2743789cbde3177515542161c3d04b164\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlist.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\ninterface IAllowlist {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xf55e4d678d05bc5d0e24ec5f24504d7437b885e19579f9d29152748c3c1c732e\",\"license\":\"MIT\"},\"contracts/interfaces/IMasterRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\ninterface IMasterRegistry {\\n /* Structs */\\n\\n struct ReverseRegistryData {\\n bytes32 name;\\n uint256 version;\\n }\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param registryName name for the registry\\n * @param registryAddress address of the new registry\\n */\\n function addRegistry(bytes32 registryName, address registryAddress)\\n external\\n payable;\\n\\n /**\\n * @notice Resolves a name to the latest registry address. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToLatestAddress(bytes32 name)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name and version to an address. Reverts if there is no registry with given name and version.\\n * @param name address of the registry you want to resolve to\\n * @param version version of the registry you want to resolve to\\n */\\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name to an array of all addresses. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToAllAddresses(bytes32 name)\\n external\\n view\\n returns (address[] memory);\\n\\n /**\\n * @notice Resolves an address to registry entry data.\\n * @param registryAddress address of a registry you want to resolve\\n * @return name name of the resolved registry\\n * @return version version of the resolved registry\\n * @return isLatest boolean flag of whether the given address is the latest version of the given registries with\\n * matching name\\n */\\n function resolveAddressToRegistryData(address registryAddress)\\n external\\n view\\n returns (\\n bytes32 name,\\n uint256 version,\\n bool isLatest\\n );\\n}\\n\",\"keccak256\":\"0x0e403d7e259003f3826b3009ae3e39344706d7af8a0a5bd48ba45a6ca978226b\",\"license\":\"MIT\"},\"contracts/interfaces/IMetaSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./ISwap.sol\\\";\\n\\ninterface IMetaSwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function isGuarded() external view returns (bool);\\n\\n function metaSwapStorage()\\n external\\n view\\n returns (\\n address baseSwap,\\n uint256 baseVirtualPrice,\\n uint256 baseCacheLastUpdated\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateSwapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function initializeMetaSwap(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress,\\n ISwap baseSwap\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function swapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x9392f53aaf25e15dbe85bf92477c1bf526ab70c00c5e4cd389da8e12e061c1d1\",\"license\":\"MIT\"},\"contracts/interfaces/IMetaSwapDeposit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./ISwap.sol\\\";\\nimport \\\"./IMetaSwap.sol\\\";\\n\\ninterface IMetaSwapDeposit {\\n function initialize(\\n ISwap _baseSwap,\\n IMetaSwap _metaSwap,\\n IERC20 _metaLPToken\\n ) external;\\n}\\n\",\"keccak256\":\"0xbc15e79f6d08b7d07b450ff6f5961eadf1c867b0f85feb59503874b719a2cd59\",\"license\":\"MIT\"},\"contracts/interfaces/IPoolRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IPoolRegistry {\\n /* Structs */\\n\\n struct PoolInputData {\\n address poolAddress;\\n uint8 typeOfAsset;\\n bytes32 poolName;\\n address targetAddress;\\n address metaSwapDepositAddress;\\n bool isSaddleApproved;\\n bool isRemoved;\\n bool isGuarded;\\n }\\n\\n struct PoolData {\\n address poolAddress;\\n address lpToken;\\n uint8 typeOfAsset;\\n bytes32 poolName;\\n address targetAddress;\\n IERC20[] tokens;\\n IERC20[] underlyingTokens;\\n address basePoolAddress;\\n address metaSwapDepositAddress;\\n bool isSaddleApproved;\\n bool isRemoved;\\n bool isGuarded;\\n }\\n\\n struct SwapStorageData {\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n uint256 swapFee;\\n uint256 adminFee;\\n address lpToken;\\n }\\n\\n /* Public Variables */\\n\\n /**\\n * @notice Returns the index + 1 of the pool address in the registry\\n * @param poolAddress address to look for\\n */\\n function poolsIndexOfPlusOne(address poolAddress)\\n external\\n returns (uint256);\\n\\n /**\\n * @notice Returns the index + 1 of the pool name in the registry\\n * @param poolName pool name in bytes32 format to look for\\n */\\n function poolsIndexOfNamePlusOne(bytes32 poolName)\\n external\\n returns (uint256);\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new pool to the registry\\n * @param inputData PoolInputData struct for the new pool\\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\\n * Only Swap and MetaSwap contracts need to be added.\\n */\\n function addPool(PoolInputData memory inputData) external payable;\\n\\n /**\\n * @notice Add a new pool to the registry\\n * @param data PoolInputData struct for the new pool\\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\\n * Only Swap and MetaSwap contracts need to be added.\\n */\\n function addCommunityPool(PoolData memory data) external payable;\\n\\n /**\\n * @notice Approve community deployed pools to be upgraded as Saddle owned\\n * @dev since array entries are difficult to remove, we modify the entry to mark it\\n * as a Saddle owned pool.\\n * @param poolAddress address of the community pool\\n */\\n function approvePool(address poolAddress) external payable;\\n\\n /**\\n * @notice Overwrite existing entry with new PoolData\\n * @param poolData new PoolData struct to store\\n */\\n function updatePool(PoolData memory poolData) external payable;\\n\\n /**\\n * @notice Remove pool from the registry\\n * @dev Since arrays are not easily reducable, the entry will be marked as removed.\\n * @param poolAddress address of the pool to remove\\n */\\n function removePool(address poolAddress) external payable;\\n\\n /**\\n * @notice Returns PoolData for given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getPoolData(address poolAddress)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns PoolData at given index\\n * @param index index of the pool to read\\n */\\n function getPoolDataAtIndex(uint256 index)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns PoolData with given name\\n * @param poolName name of the pool to read\\n */\\n function getPoolDataByName(bytes32 poolName)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns virtual price of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getVirtualPrice(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @notice Returns A of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getA(address poolAddress) external view returns (uint256);\\n\\n /**\\n * @notice Returns the paused status of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getPaused(address poolAddress) external view returns (bool);\\n\\n /**\\n * @notice Returns the SwapStorage struct of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getSwapStorage(address poolAddress)\\n external\\n view\\n returns (SwapStorageData memory swapStorageData);\\n\\n /**\\n * @notice Returns the tokens of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getTokens(address poolAddress)\\n external\\n view\\n returns (IERC20[] memory);\\n\\n /**\\n * @notice Returns the underlying tokens of the given pool address. Base pools will return an empty array.\\n * @param poolAddress address of the pool to read\\n */\\n function getUnderlyingTokens(address poolAddress)\\n external\\n view\\n returns (IERC20[] memory);\\n\\n /**\\n * @notice Returns number of entries in the registry. Includes removed pools\\n * in the list as well.\\n */\\n function getPoolsLength() external view returns (uint256);\\n\\n /**\\n * @notice Returns an array of pool addresses that can swap between from and to\\n * @param from address of the token to swap from\\n * @param to address of the token to swap to\\n * @return eligiblePools array of pool addresses that can swap between from and to\\n */\\n function getEligiblePools(address from, address to)\\n external\\n view\\n returns (address[] memory eligiblePools);\\n\\n /**\\n * @notice Returns an array of balances of the tokens\\n * @param poolAddress address of the pool to look up the token balances for\\n * @return balances array of token balances\\n */\\n function getTokenBalances(address poolAddress)\\n external\\n view\\n returns (uint256[] memory balances);\\n\\n /**\\n * @notice Returns an array of balances of the tokens\\n * @param poolAddress address of the pool to look up the token balances for\\n * @return balances array of token balances\\n */\\n function getUnderlyingTokenBalances(address poolAddress)\\n external\\n view\\n returns (uint256[] memory balances);\\n}\\n\",\"keccak256\":\"0x7f51230d9e9229a935312bd05f5e93ab8fbb38e6635bbfb9402001b86a795bb2\",\"license\":\"MIT\"},\"contracts/interfaces/ISwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlist.sol\\\";\\n\\ninterface ISwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlist);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xcd26195c5e3824e7984750a05c9fcb6dde3e266022c3bd1a9dcdda9e967a6f4c\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessDeployer.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/Clones.sol\\\";\\nimport \\\"../interfaces/ISwap.sol\\\";\\nimport \\\"../interfaces/IMetaSwap.sol\\\";\\nimport \\\"../interfaces/IMetaSwapDeposit.sol\\\";\\nimport \\\"../interfaces/IPoolRegistry.sol\\\";\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\n\\n/**\\n * @title PermissionlessDeployer\\n * @notice Allows for anyone to indepentantly deploy pools and meta pools of given tokens. A user will set\\n * custom parameters for the pool such as the trading/admin fees, as well as the a-parameter.\\n *\\n * Ownership of the pools are given to the deploying address. Saddle will collect 50% of the trading fees earned\\n * by the pool.\\n */\\ncontract PermissionlessDeployer is AccessControl {\\n IMasterRegistry public immutable MASTER_REGISTRY;\\n bytes32 public constant POOL_REGISTRY_NAME =\\n 0x506f6f6c52656769737472790000000000000000000000000000000000000000;\\n\\n /// @notice Role responsible for managing target addresses\\n bytes32 public constant SADDLE_MANAGER_ROLE =\\n keccak256(\\\"SADDLE_MANAGER_ROLE\\\");\\n\\n address public targetLPToken;\\n address public targetSwap;\\n address public targetMetaSwap;\\n address public targetMetaSwapDeposit;\\n string public constant LP_TOKEN_NAME0 = \\\"Saddle \\\";\\n string public constant LP_TOKEN_NAME1 = \\\" LP Token\\\";\\n\\n IPoolRegistry public poolRegistryCached;\\n\\n /**\\n * @notice Emmited when a new pool is deployed\\n * @param deployer address of the deployer\\n * @param swapAddress address of the deployed pool\\n * @param pooledTokens, array of addresses of the tokens in the pool\\n */\\n event NewSwapPool(\\n address indexed deployer,\\n address swapAddress,\\n IERC20[] pooledTokens\\n );\\n\\n event NewClone(address indexed target, address cloneAddress);\\n\\n /**\\n * @notice Emmited when the pool registry cache is updated\\n * @param poolRegistry address of the current Saddle Pool Registry\\n */\\n event PoolRegistryUpdated(address indexed poolRegistry);\\n event TargetLPTokenUpdated(address indexed target);\\n event TargetSwapUpdated(address indexed target);\\n event TargetMetaSwapUpdated(address indexed target);\\n event TargetMetaSwapDepositUpdated(address indexed target);\\n\\n struct DeploySwapInput {\\n bytes32 poolName; // name of the pool\\n IERC20[] tokens; // array of addresses of the tokens in the pool\\n uint8[] decimals; // array of decimals of the tokens in the pool\\n string lpTokenSymbol; // symbol of the LPToken\\n uint256 a; // a-parameter of the pool\\n uint256 fee; // trading fee of the pool\\n uint256 adminFee; // admin fee of the pool\\n address owner; // owner address of the pool\\n uint8 typeOfAsset; // USD/BTC/ETH/OTHER\\n }\\n\\n struct DeployMetaSwapInput {\\n bytes32 poolName; // name of the pool\\n IERC20[] tokens; // array of addresses of the tokens in the pool\\n uint8[] decimals; // array of decimals of the tokens in the pool\\n string lpTokenSymbol; // symbol of the LPToken\\n uint256 a; // a-parameter of the pool\\n uint256 fee; // trading fee of the pool\\n uint256 adminFee; // admin fee of the pool\\n address baseSwap; // address of the basepool\\n address owner; // owner address of the pool\\n uint8 typeOfAsset; // USD/BTC/ETH/OTHER\\n }\\n\\n constructor(\\n address admin,\\n address _masterRegistry,\\n address _targetLPToken,\\n address _targetSwap,\\n address _targetMetaSwap,\\n address _targetMetaSwapDeposit\\n ) public payable {\\n require(admin != address(0), \\\"admin == 0\\\");\\n require(_masterRegistry != address(0), \\\"masterRegistry == 0\\\");\\n\\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\\n\\n _setTargetLPToken(_targetLPToken);\\n _setTargetSwap(_targetSwap);\\n _setTargetMetaSwap(_targetMetaSwap);\\n _setTargetMetaSwapDeposit(_targetMetaSwapDeposit);\\n\\n MASTER_REGISTRY = IMasterRegistry(_masterRegistry);\\n _updatePoolRegistryCache(_masterRegistry);\\n }\\n\\n modifier onlyManager() {\\n require(hasRole(SADDLE_MANAGER_ROLE, msg.sender), \\\"only manager\\\");\\n _;\\n }\\n\\n /**\\n * @notice Uses openzeppelin's clone mechanism to clone an existing a pool for cheaper deployments.\\n * @param target the address of the target pool to be cloned\\n * @return newClone an address of the cloned pool\\n */\\n function clone(address target) public payable returns (address newClone) {\\n newClone = Clones.clone(target);\\n emit NewClone(target, newClone);\\n }\\n\\n /**\\n * @notice Deploys a new pool, adds an entry in the Saddle Pool Registry.\\n * @param input, a struct containing the input parameters for the pool to be deployed,\\n * must include a unique pool name.\\n * @return deployedSwap the address of the deployed pool.\\n */\\n\\n function deploySwap(DeploySwapInput memory input)\\n external\\n payable\\n returns (address deployedSwap)\\n {\\n require(\\n poolRegistryCached.poolsIndexOfNamePlusOne(input.poolName) == 0,\\n \\\"pool name already exists\\\"\\n );\\n\\n address swapClone = clone(targetSwap);\\n\\n ISwap(swapClone).initialize(\\n input.tokens,\\n input.decimals,\\n string(\\n abi.encodePacked(\\n LP_TOKEN_NAME0,\\n input.lpTokenSymbol,\\n LP_TOKEN_NAME1\\n )\\n ),\\n input.lpTokenSymbol,\\n input.a,\\n input.fee,\\n input.adminFee,\\n targetLPToken\\n );\\n Ownable(swapClone).transferOwnership(input.owner);\\n (, , , , , , address lpToken) = ISwap(swapClone).swapStorage();\\n\\n IPoolRegistry.PoolData memory poolData = IPoolRegistry.PoolData({\\n poolAddress: swapClone,\\n lpToken: lpToken,\\n typeOfAsset: input.typeOfAsset,\\n poolName: input.poolName,\\n targetAddress: targetSwap,\\n tokens: input.tokens,\\n underlyingTokens: new IERC20[](0),\\n basePoolAddress: address(0),\\n metaSwapDepositAddress: address(0),\\n isSaddleApproved: false,\\n isRemoved: false,\\n isGuarded: false\\n });\\n\\n emit NewSwapPool(msg.sender, swapClone, input.tokens);\\n\\n poolRegistryCached.addCommunityPool(poolData);\\n return swapClone;\\n }\\n\\n /**\\n * @notice Deploys a new meta pool.\\n * @param input, a DeployMetaSwapInput struct containing the input parameters for the meta pool.\\n */\\n function deployMetaSwap(DeployMetaSwapInput memory input)\\n external\\n payable\\n returns (address deployedMetaSwap, address deployedMetaSwapDeposit)\\n {\\n require(\\n poolRegistryCached.poolsIndexOfNamePlusOne(input.poolName) == 0,\\n \\\"pool name already exists\\\"\\n );\\n\\n deployedMetaSwap = clone(targetMetaSwap);\\n IMetaSwap(deployedMetaSwap).initializeMetaSwap(\\n input.tokens,\\n input.decimals,\\n string(\\n abi.encodePacked(\\n LP_TOKEN_NAME0,\\n input.lpTokenSymbol,\\n LP_TOKEN_NAME1\\n )\\n ),\\n input.lpTokenSymbol,\\n input.a,\\n input.fee,\\n input.adminFee,\\n targetLPToken,\\n ISwap(input.baseSwap)\\n );\\n (, , , , , , address lpToken) = ISwap(deployedMetaSwap).swapStorage();\\n Ownable(deployedMetaSwap).transferOwnership(input.owner);\\n\\n deployedMetaSwapDeposit = clone(targetMetaSwapDeposit);\\n IMetaSwapDeposit(deployedMetaSwapDeposit).initialize(\\n ISwap(input.baseSwap),\\n IMetaSwap(deployedMetaSwap),\\n IERC20(lpToken)\\n );\\n\\n IERC20[] memory baseTokens = poolRegistryCached.getTokens(\\n input.baseSwap\\n ); // revert if baseSwap is not registered\\n IERC20[] memory underlyingTokens = new IERC20[](\\n input.tokens.length - 1 + baseTokens.length\\n );\\n uint256 metaLPTokenIndex = input.tokens.length - 1;\\n for (uint256 i = 0; i < metaLPTokenIndex; i++) {\\n underlyingTokens[i] = input.tokens[i];\\n }\\n for (uint256 i = metaLPTokenIndex; i < underlyingTokens.length; i++) {\\n underlyingTokens[i] = baseTokens[i - metaLPTokenIndex];\\n }\\n\\n IPoolRegistry.PoolData memory poolData = IPoolRegistry.PoolData({\\n poolAddress: deployedMetaSwap,\\n lpToken: lpToken,\\n typeOfAsset: input.typeOfAsset,\\n poolName: input.poolName,\\n targetAddress: targetSwap,\\n tokens: input.tokens,\\n underlyingTokens: underlyingTokens,\\n basePoolAddress: input.baseSwap,\\n metaSwapDepositAddress: deployedMetaSwapDeposit,\\n isSaddleApproved: false,\\n isRemoved: false,\\n isGuarded: false\\n });\\n\\n emit NewSwapPool(msg.sender, deployedMetaSwap, input.tokens);\\n emit NewSwapPool(msg.sender, deployedMetaSwapDeposit, underlyingTokens);\\n\\n poolRegistryCached.addCommunityPool(poolData);\\n }\\n\\n /**\\n * @notice Updates cached address of the pool registry **should be onlymanager?\\n */\\n function updatePoolRegistryCache() external {\\n _updatePoolRegistryCache(address(MASTER_REGISTRY));\\n }\\n\\n function _updatePoolRegistryCache(address masterRegistry) internal {\\n poolRegistryCached = IPoolRegistry(\\n IMasterRegistry(masterRegistry).resolveNameToLatestAddress(\\n POOL_REGISTRY_NAME\\n )\\n );\\n }\\n\\n function setTargetLPToken(address _targetLPToken)\\n external\\n payable\\n onlyManager\\n {\\n _setTargetLPToken(_targetLPToken);\\n }\\n\\n function _setTargetLPToken(address _targetLPToken) internal {\\n require(\\n address(_targetLPToken) != address(0),\\n \\\"Target LPToken cannot be 0\\\"\\n );\\n targetLPToken = _targetLPToken;\\n emit TargetLPTokenUpdated(_targetLPToken);\\n }\\n\\n function setTargetSwap(address _targetSwap) external payable onlyManager {\\n _setTargetSwap(_targetSwap);\\n }\\n\\n function _setTargetSwap(address _targetSwap) internal {\\n require(address(_targetSwap) != address(0), \\\"Target Swap cannot be 0\\\");\\n targetSwap = _targetSwap;\\n emit TargetSwapUpdated(_targetSwap);\\n }\\n\\n function setTargetMetaSwap(address _targetMetaSwap)\\n public\\n payable\\n onlyManager\\n {\\n _setTargetMetaSwap(_targetMetaSwap);\\n }\\n\\n function _setTargetMetaSwap(address _targetMetaSwap) internal {\\n require(\\n address(_targetMetaSwap) != address(0),\\n \\\"Target MetaSwap cannot be 0\\\"\\n );\\n targetMetaSwap = _targetMetaSwap;\\n emit TargetMetaSwapUpdated(_targetMetaSwap);\\n }\\n\\n function setTargetMetaSwapDeposit(address _targetMetaSwapDeposit)\\n external\\n payable\\n onlyManager\\n {\\n _setTargetMetaSwapDeposit(_targetMetaSwapDeposit);\\n }\\n\\n function _setTargetMetaSwapDeposit(address _targetMetaSwapDeposit)\\n internal\\n {\\n require(\\n address(_targetMetaSwapDeposit) != address(0),\\n \\\"Target MetaSwapDeposit cannot be 0\\\"\\n );\\n targetMetaSwapDeposit = _targetMetaSwapDeposit;\\n emit TargetMetaSwapDepositUpdated(_targetMetaSwapDeposit);\\n }\\n}\\n\",\"keccak256\":\"0x4f16de7dd2e8ffdd088c002325ed0b5b84d0960553f61373d4e5b8823e112103\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a060405260405162002dcf38038062002dcf8339810160408190526200002691620004d9565b6001600160a01b038616620000585760405162461bcd60e51b81526004016200004f9062000686565b60405180910390fd5b6001600160a01b038516620000815760405162461bcd60e51b81526004016200004f906200059f565b6200008e6000876200010f565b620000ba7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd336200010f565b620000c5846200011f565b620000d08362000192565b620000db8262000205565b620000e68162000278565b6001600160601b0319606086901b166080526200010385620002eb565b505050505050620006aa565b6200011b82826200039f565b5050565b6001600160a01b038116620001485760405162461bcd60e51b81526004016200004f9062000568565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f336ea638298c0cea1e72c71ed04716bef23a7a6251478299d7ca4067fea0c47990600090a250565b6001600160a01b038116620001bb5760405162461bcd60e51b81526004016200004f90620005d6565b600280546001600160a01b0319166001600160a01b0383169081179091556040517f6c149d1850b03102a8ac77fc865c12f017f4fb8bf9f9af345d36b0e8b60bcc8590600090a250565b6001600160a01b0381166200022e5760405162461bcd60e51b81526004016200004f906200064f565b600380546001600160a01b0319166001600160a01b0383169081179091556040517f06fc5602fc767cbb172d176a4cd0531d747abbdd090065ebd7b63ee4d2f0b44d90600090a250565b6001600160a01b038116620002a15760405162461bcd60e51b81526004016200004f906200060d565b600480546001600160a01b0319166001600160a01b0383169081179091556040517f768ccdac0361ba56b697aa598fdd415f51a59d121b9d2b50714d3072cc4a8f1790600090a250565b604051633705f62560e01b81526001600160a01b03821690633705f6259062000328906b506f6f6c526567697374727960a01b906004016200055f565b60206040518083038186803b1580156200034157600080fd5b505afa15801562000356573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200037c9190620004bb565b600580546001600160a01b0319166001600160a01b039290921691909117905550565b600082815260208181526040909120620003c49183906200139362000418821b17901c565b156200011b57620003d462000438565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006200042f836001600160a01b0384166200043c565b90505b92915050565b3390565b60006200044a83836200048b565b620004825750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000432565b50600062000432565b60009081526001919091016020526040902054151590565b80516001600160a01b03811681146200043257600080fd5b600060208284031215620004cd578081fd5b6200042f8383620004a3565b60008060008060008060c08789031215620004f2578182fd5b620004fe8888620004a3565b95506200050f8860208901620004a3565b9450620005208860408901620004a3565b9350620005318860608901620004a3565b9250620005428860808901620004a3565b9150620005538860a08901620004a3565b90509295509295509295565b90815260200190565b6020808252601a908201527f546172676574204c50546f6b656e2063616e6e6f742062652030000000000000604082015260600190565b60208082526013908201527f6d61737465725265676973747279203d3d203000000000000000000000000000604082015260600190565b60208082526017908201527f54617267657420537761702063616e6e6f742062652030000000000000000000604082015260600190565b60208082526022908201527f546172676574204d657461537761704465706f7369742063616e6e6f74206265604082015261020360f41b606082015260800190565b6020808252601b908201527f546172676574204d657461537761702063616e6e6f7420626520300000000000604082015260600190565b6020808252600a9082015269061646d696e203d3d20360b41b604082015260600190565b60805160601c612702620006cd60003980610d3c5280610d6452506127026000f3fe6080604052600436106101a05760003560e01c8063a132d9b5116100e1578063b636f24a1161008a578063cce061e011610064578063cce061e0146103f8578063d547741f1461040d578063df0c1cf01461042d578063e1a58c3d14610440576101a0565b8063b636f24a146103b0578063bbe7d6b7146103c5578063ca15c873146103d8576101a0565b8063ac841ed9116100bb578063ac841ed914610366578063afa9502e1461037b578063b3a316b01461038e576101a0565b8063a132d9b514610329578063a217fddf1461033c578063a50d7d8514610351576101a0565b806336568abe1161014e5780636d2f2246116101285780636d2f2246146102b45780638124b78e146102c95780639010d07c146102dc57806391d14854146102fc576101a0565b806336568abe1461026a5780633c7958401461028a5780634f8d446b1461029f576101a0565b8063248a9ca31161017f578063248a9ca3146102065780632f2ff15d1461023357806333ba0efc14610255576101a0565b8062fc2fc0146101a55780630831cbb7146101cf57806321fcbe05146101f1575b600080fd5b6101b86101b3366004611cf3565b610453565b6040516101c692919061208e565b60405180910390f35b3480156101db57600080fd5b506101e4610b2e565b6040516101c6919061207a565b3480156101fd57600080fd5b506101e4610b3d565b34801561021257600080fd5b50610226610221366004611c8b565b610b4c565b6040516101c691906121e8565b34801561023f57600080fd5b5061025361024e366004611ca3565b610b64565b005b34801561026157600080fd5b506101e4610bac565b34801561027657600080fd5b50610253610285366004611ca3565b610bbb565b34801561029657600080fd5b506101e4610bfd565b3480156102ab57600080fd5b50610226610c0c565b3480156102c057600080fd5b50610226610c30565b6101e46102d7366004611bb4565b610c54565b3480156102e857600080fd5b506101e46102f7366004611cd2565b610ca7565b34801561030857600080fd5b5061031c610317366004611ca3565b610cc8565b6040516101c691906121dd565b610253610337366004611bb4565b610ce0565b34801561034857600080fd5b50610226610d32565b34801561035d57600080fd5b50610253610d37565b34801561037257600080fd5b506101e4610d62565b6101e4610389366004611e0e565b610d86565b34801561039a57600080fd5b506103a36111d4565b6040516101c69190612214565b3480156103bc57600080fd5b506103a361120d565b6102536103d3366004611bb4565b611246565b3480156103e457600080fd5b506102266103f3366004611c8b565b611295565b34801561040457600080fd5b506101e46112ac565b34801561041957600080fd5b50610253610428366004611ca3565b6112bb565b61025361043b366004611bb4565b6112f5565b61025361044e366004611bb4565b611344565b60055481516040517f5b506a0000000000000000000000000000000000000000000000000000000000815260009283926001600160a01b0390911691635b506a00916104a1916004016121e8565b602060405180830381600087803b1580156104bb57600080fd5b505af11580156104cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f39190611f05565b156105195760405162461bcd60e51b8152600401610510906122e1565b60405180910390fd5b60035461052e906001600160a01b0316610c54565b9150816001600160a01b031663118e1c77846020015185604001516040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525087606001516040518060400160405280600981526020017f204c5020546f6b656e00000000000000000000000000000000000000000000008152506040516020016105cc93929190612037565b60408051808303601f1901815290829052606089015160808a015160a08b015160c08c015160015460e0808f0151908b901b7fffffffff0000000000000000000000000000000000000000000000000000000016885261063c9998976001600160a01b0390921691600401612153565b600060405180830381600087803b15801561065657600080fd5b505af115801561066a573d6000803e3d6000fd5b505050506000826001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156106a957600080fd5b505afa1580156106bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e19190611f1d565b9650505050505050826001600160a01b031663f2fde38b8561010001516040518263ffffffff1660e01b815260040161071a919061207a565b600060405180830381600087803b15801561073457600080fd5b505af1158015610748573d6000803e3d6000fd5b505060045461076292506001600160a01b03169050610c54565b60e08501516040517fc0c53b8b0000000000000000000000000000000000000000000000000000000081529193506001600160a01b0384169163c0c53b8b916107b191879086906004016121f1565b600060405180830381600087803b1580156107cb57600080fd5b505af11580156107df573d6000803e3d6000fd5b505060055460e08701516040517f450efe21000000000000000000000000000000000000000000000000000000008152606094506001600160a01b03909216925063450efe2191610833919060040161207a565b60006040518083038186803b15801561084b57600080fd5b505afa15801561085f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108879190810190611bf3565b9050606081516001876020015151030167ffffffffffffffff811180156108ad57600080fd5b506040519080825280602002602001820160405280156108d7578160200160208202803683370190505b506020870151519091507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160005b81811015610952578760200151818151811061091e57fe5b602002602001015183828151811061093257fe5b6001600160a01b0390921660209283029190910190910152600101610906565b50805b82518110156109a057838282038151811061096c57fe5b602002602001015183828151811061098057fe5b6001600160a01b0390921660209283029190910190910152600101610955565b506109a96119e4565b5060408051610180810182526001600160a01b038089168252868116602080840191909152610120808c015160ff16848601528b51606085015260025483166080850152908b01805160a085015260c0840187905260e0808d015184169085015291891661010084015260009083018190526101408301819052610160830152519151909133917f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d991610a5e918b91906120a8565b60405180910390a2336001600160a01b03167f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d98785604051610aa19291906120a8565b60405180910390a26005546040517f8a754bbe0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690638a754bbe90610af2908490600401612542565b600060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050505050505050915091565b6004546001600160a01b031681565b6001546001600160a01b031681565b6000818152602081905260409020600201545b919050565b600082815260208190526040902060020154610b82906103176113a8565b610b9e5760405162461bcd60e51b815260040161051090612284565b610ba882826113ac565b5050565b6005546001600160a01b031681565b610bc36113a8565b6001600160a01b0316816001600160a01b031614610bf35760405162461bcd60e51b8152600401610510906124e5565b610ba88282611415565b6003546001600160a01b031681565b7f506f6f6c5265676973747279000000000000000000000000000000000000000081565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6000610c5f8261147e565b9050816001600160a01b03167f3bf919a220a0f12ddcaf77fd06ffa4b9c728617774936f0d78b452010319c82482604051610c9a919061207a565b60405180910390a2919050565b6000828152602081905260408120610cbf9083611504565b90505b92915050565b6000828152602081905260408120610cbf9083611510565b610d0a7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b610d265760405162461bcd60e51b81526004016105109061234f565b610d2f81611525565b50565b600081565b610d607f00000000000000000000000000000000000000000000000000000000000000006115ad565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b60055481516040517f5b506a000000000000000000000000000000000000000000000000000000000081526000926001600160a01b031691635b506a0091610dd191906004016121e8565b602060405180830381600087803b158015610deb57600080fd5b505af1158015610dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e239190611f05565b15610e405760405162461bcd60e51b8152600401610510906122e1565b600254600090610e58906001600160a01b0316610c54565b9050806001600160a01b031663b28cb6dc846020015185604001516040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525087606001516040518060400160405280600981526020017f204c5020546f6b656e0000000000000000000000000000000000000000000000815250604051602001610ef693929190612037565b60408051601f1981840301815290829052606089015160808a015160a08b015160c08c01516001547fffffffff0000000000000000000000000000000000000000000000000000000060e08b901b168752610f619897966001600160a01b03909116906004016120d2565b600060405180830381600087803b158015610f7b57600080fd5b505af1158015610f8f573d6000803e3d6000fd5b50505060e08401516040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b038416925063f2fde38b91610fdb9160040161207a565b600060405180830381600087803b158015610ff557600080fd5b505af1158015611009573d6000803e3d6000fd5b505050506000816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561104857600080fd5b505afa15801561105c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110809190611f1d565b96505050505050506110906119e4565b5060408051610180810182526001600160a01b0384811682528381166020808401919091526101008881015160ff1684860152885160608501526002549092166080840152878101805160a085015284516000808252928101865260c085015260e0840182905291830181905261012083018190526101408301819052610160830152519151909133917f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d991611148918791906120a8565b60405180910390a26005546040517f8a754bbe0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690638a754bbe90611199908490600401612542565b600060405180830381600087803b1580156111b357600080fd5b505af11580156111c7573d6000803e3d6000fd5b5094979650505050505050565b6040518060400160405280600981526020017f204c5020546f6b656e000000000000000000000000000000000000000000000081525081565b6040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525081565b6112707fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61128c5760405162461bcd60e51b81526004016105109061234f565b610d2f8161169d565b6000818152602081905260408120610cc290611725565b6002546001600160a01b031681565b6000828152602081905260409020600201546112d9906103176113a8565b610bf35760405162461bcd60e51b815260040161051090612386565b61131f7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61133b5760405162461bcd60e51b81526004016105109061234f565b610d2f81611730565b61136e7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61138a5760405162461bcd60e51b81526004016105109061234f565b610d2f816117b8565b6000610cbf836001600160a01b038416611840565b3390565b60008281526020819052604090206113c49082611393565b15610ba8576113d16113a8565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260208190526040902061142d908261188a565b15610ba85761143a6113a8565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610b5f5760405162461bcd60e51b8152600401610510906123e3565b6000610cbf838361189f565b6000610cbf836001600160a01b0384166118e4565b6001600160a01b03811661154b5760405162461bcd60e51b815260040161051090612451565b600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f768ccdac0361ba56b697aa598fdd415f51a59d121b9d2b50714d3072cc4a8f1790600090a250565b6040517f3705f6250000000000000000000000000000000000000000000000000000000081526001600160a01b03821690633705f62590611612907f506f6f6c52656769737472790000000000000000000000000000000000000000906004016121e8565b60206040518083038186803b15801561162a57600080fd5b505afa15801561163e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116629190611bd7565b600580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b6001600160a01b0381166116c35760405162461bcd60e51b8152600401610510906124ae565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f06fc5602fc767cbb172d176a4cd0531d747abbdd090065ebd7b63ee4d2f0b44d90600090a250565b6000610cc2826118fc565b6001600160a01b0381166117565760405162461bcd60e51b81526004016105109061241a565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f6c149d1850b03102a8ac77fc865c12f017f4fb8bf9f9af345d36b0e8b60bcc8590600090a250565b6001600160a01b0381166117de5760405162461bcd60e51b815260040161051090612318565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f336ea638298c0cea1e72c71ed04716bef23a7a6251478299d7ca4067fea0c47990600090a250565b600061184c83836118e4565b61188257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cc2565b506000610cc2565b6000610cbf836001600160a01b038416611900565b815460009082106118c25760405162461bcd60e51b815260040161051090612227565b8260000182815481106118d157fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156119da5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808301919081019060009087908390811061195157fe5b906000526020600020015490508087600001848154811061196e57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061199e57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610cc2565b6000915050610cc2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8035610cc2816126b7565b600082601f830112611a62578081fd5b8135611a75611a7082612667565b612640565b818152915060208083019084810181840286018201871015611a9657600080fd5b60005b84811015611abe578135611aac816126b7565b84529282019290820190600101611a99565b505050505092915050565b600082601f830112611ad9578081fd5b8135611ae7611a7082612667565b818152915060208083019084810181840286018201871015611b0857600080fd5b60005b84811015611abe57611b1d8883611ba3565b84529282019290820190600101611b0b565b8051610cc2816126b7565b600082601f830112611b4a578081fd5b813567ffffffffffffffff811115611b60578182fd5b611b736020601f19601f84011601612640565b9150808252836020828501011115611b8a57600080fd5b8060208401602084013760009082016020015292915050565b803560ff81168114610cc257600080fd5b600060208284031215611bc5578081fd5b8135611bd0816126b7565b9392505050565b600060208284031215611be8578081fd5b8151611bd0816126b7565b60006020808385031215611c05578182fd5b825167ffffffffffffffff811115611c1b578283fd5b8301601f81018513611c2b578283fd5b8051611c39611a7082612667565b8181528381019083850185840285018601891015611c55578687fd5b8694505b83851015611c7f57611c6b8982611b2f565b835260019490940193918501918501611c59565b50979650505050505050565b600060208284031215611c9c578081fd5b5035919050565b60008060408385031215611cb5578081fd5b823591506020830135611cc7816126b7565b809150509250929050565b60008060408385031215611ce4578182fd5b50508035926020909101359150565b600060208284031215611d04578081fd5b813567ffffffffffffffff80821115611d1b578283fd5b8184019150610140808387031215611d31578384fd5b611d3a81612640565b905082358152602083013582811115611d51578485fd5b611d5d87828601611a52565b602083015250604083013582811115611d74578485fd5b611d8087828601611ac9565b604083015250606083013582811115611d97578485fd5b611da387828601611b3a565b6060830152506080830135608082015260a083013560a082015260c083013560c0820152611dd48660e08501611a47565b60e08201526101009150611dea86838501611a47565b828201526101209150611dff86838501611ba3565b91810191909152949350505050565b600060208284031215611e1f578081fd5b813567ffffffffffffffff80821115611e36578283fd5b8184019150610120808387031215611e4c578384fd5b611e5581612640565b905082358152602083013582811115611e6c578485fd5b611e7887828601611a52565b602083015250604083013582811115611e8f578485fd5b611e9b87828601611ac9565b604083015250606083013582811115611eb2578485fd5b611ebe87828601611b3a565b6060830152506080830135608082015260a083013560a082015260c083013560c0820152611eef8660e08501611a47565b60e08201526101009150611dff86838501611ba3565b600060208284031215611f16578081fd5b5051919050565b600080600080600080600060e0888a031215611f37578283fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c0880151611f6c816126b7565b8091505092959891949750929550565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015611fc15781516001600160a01b031687529582019590820190600101611f9c565b509495945050505050565b6000815180845260208085019450808401835b83811015611fc157815160ff1687529582019590820190600101611fdf565b15159052565b6000815180845261201c816020860160208601612687565b601f01601f19169290920160200192915050565b60ff169052565b60008451612049818460208901612687565b84519083019061205d818360208901612687565b8451910190612070818360208801612687565b0195945050505050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b60006001600160a01b0384168252604060208301526120ca6040830184611f89565b949350505050565b60006101008083526120e68184018c611f89565b905082810360208401526120fa818b611fcc565b9050828103604084015261210e818a612004565b905082810360608401526121228189612004565b9150508560808301528460a08301528360c08301526001600160a01b03831660e08301529998505050505050505050565b60006101208083526121678184018d611f89565b9050828103602084015261217b818c611fcc565b9050828103604084015261218f818b612004565b905082810360608401526121a3818a612004565b6080840198909852505060a081019490945260c08401929092526001600160a01b0390811660e08401521661010090910152949350505050565b901515815260200190565b90815260200190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b600060208252610cbf6020830184612004565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b60208082526018908201527f706f6f6c206e616d6520616c7265616479206578697374730000000000000000604082015260600190565b6020808252601a908201527f546172676574204c50546f6b656e2063616e6e6f742062652030000000000000604082015260600190565b6020808252600c908201527f6f6e6c79206d616e616765720000000000000000000000000000000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b60208082526016908201527f455243313136373a20637265617465206661696c656400000000000000000000604082015260600190565b60208082526017908201527f54617267657420537761702063616e6e6f742062652030000000000000000000604082015260600190565b60208082526022908201527f546172676574204d657461537761704465706f7369742063616e6e6f7420626560408201527f2030000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f546172676574204d657461537761702063616e6e6f7420626520300000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252612556602083018451611f7c565b60208301516125686040840182611f7c565b50604083015161257b6060840182612030565b5060608301516080830152608083015161259860a0840182611f7c565b5060a08301516101808060c08501526125b56101a0850183611f89565b915060c0850151601f198584030160e08601526125d28382611f89565b92505060e08501516101006125e981870183611f7c565b86015190506101206125fd86820183611f7c565b860151905061014061261186820183611ffe565b860151905061016061262586820183611ffe565b860151905061263685830182611ffe565b5090949350505050565b60405181810167ffffffffffffffff8111828210171561265f57600080fd5b604052919050565b600067ffffffffffffffff82111561267d578081fd5b5060209081020190565b60005b838110156126a257818101518382015260200161268a565b838111156126b1576000848401525b50505050565b6001600160a01b0381168114610d2f57600080fdfea2646970667358221220d56422b9e463c0dcb41b8cca0dcd51818946ab0781666fb5f3badcc92cb3841564736f6c634300060c0033", + "deployedBytecode": "0x6080604052600436106101a05760003560e01c8063a132d9b5116100e1578063b636f24a1161008a578063cce061e011610064578063cce061e0146103f8578063d547741f1461040d578063df0c1cf01461042d578063e1a58c3d14610440576101a0565b8063b636f24a146103b0578063bbe7d6b7146103c5578063ca15c873146103d8576101a0565b8063ac841ed9116100bb578063ac841ed914610366578063afa9502e1461037b578063b3a316b01461038e576101a0565b8063a132d9b514610329578063a217fddf1461033c578063a50d7d8514610351576101a0565b806336568abe1161014e5780636d2f2246116101285780636d2f2246146102b45780638124b78e146102c95780639010d07c146102dc57806391d14854146102fc576101a0565b806336568abe1461026a5780633c7958401461028a5780634f8d446b1461029f576101a0565b8063248a9ca31161017f578063248a9ca3146102065780632f2ff15d1461023357806333ba0efc14610255576101a0565b8062fc2fc0146101a55780630831cbb7146101cf57806321fcbe05146101f1575b600080fd5b6101b86101b3366004611cf3565b610453565b6040516101c692919061208e565b60405180910390f35b3480156101db57600080fd5b506101e4610b2e565b6040516101c6919061207a565b3480156101fd57600080fd5b506101e4610b3d565b34801561021257600080fd5b50610226610221366004611c8b565b610b4c565b6040516101c691906121e8565b34801561023f57600080fd5b5061025361024e366004611ca3565b610b64565b005b34801561026157600080fd5b506101e4610bac565b34801561027657600080fd5b50610253610285366004611ca3565b610bbb565b34801561029657600080fd5b506101e4610bfd565b3480156102ab57600080fd5b50610226610c0c565b3480156102c057600080fd5b50610226610c30565b6101e46102d7366004611bb4565b610c54565b3480156102e857600080fd5b506101e46102f7366004611cd2565b610ca7565b34801561030857600080fd5b5061031c610317366004611ca3565b610cc8565b6040516101c691906121dd565b610253610337366004611bb4565b610ce0565b34801561034857600080fd5b50610226610d32565b34801561035d57600080fd5b50610253610d37565b34801561037257600080fd5b506101e4610d62565b6101e4610389366004611e0e565b610d86565b34801561039a57600080fd5b506103a36111d4565b6040516101c69190612214565b3480156103bc57600080fd5b506103a361120d565b6102536103d3366004611bb4565b611246565b3480156103e457600080fd5b506102266103f3366004611c8b565b611295565b34801561040457600080fd5b506101e46112ac565b34801561041957600080fd5b50610253610428366004611ca3565b6112bb565b61025361043b366004611bb4565b6112f5565b61025361044e366004611bb4565b611344565b60055481516040517f5b506a0000000000000000000000000000000000000000000000000000000000815260009283926001600160a01b0390911691635b506a00916104a1916004016121e8565b602060405180830381600087803b1580156104bb57600080fd5b505af11580156104cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f39190611f05565b156105195760405162461bcd60e51b8152600401610510906122e1565b60405180910390fd5b60035461052e906001600160a01b0316610c54565b9150816001600160a01b031663118e1c77846020015185604001516040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525087606001516040518060400160405280600981526020017f204c5020546f6b656e00000000000000000000000000000000000000000000008152506040516020016105cc93929190612037565b60408051808303601f1901815290829052606089015160808a015160a08b015160c08c015160015460e0808f0151908b901b7fffffffff0000000000000000000000000000000000000000000000000000000016885261063c9998976001600160a01b0390921691600401612153565b600060405180830381600087803b15801561065657600080fd5b505af115801561066a573d6000803e3d6000fd5b505050506000826001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156106a957600080fd5b505afa1580156106bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e19190611f1d565b9650505050505050826001600160a01b031663f2fde38b8561010001516040518263ffffffff1660e01b815260040161071a919061207a565b600060405180830381600087803b15801561073457600080fd5b505af1158015610748573d6000803e3d6000fd5b505060045461076292506001600160a01b03169050610c54565b60e08501516040517fc0c53b8b0000000000000000000000000000000000000000000000000000000081529193506001600160a01b0384169163c0c53b8b916107b191879086906004016121f1565b600060405180830381600087803b1580156107cb57600080fd5b505af11580156107df573d6000803e3d6000fd5b505060055460e08701516040517f450efe21000000000000000000000000000000000000000000000000000000008152606094506001600160a01b03909216925063450efe2191610833919060040161207a565b60006040518083038186803b15801561084b57600080fd5b505afa15801561085f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108879190810190611bf3565b9050606081516001876020015151030167ffffffffffffffff811180156108ad57600080fd5b506040519080825280602002602001820160405280156108d7578160200160208202803683370190505b506020870151519091507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160005b81811015610952578760200151818151811061091e57fe5b602002602001015183828151811061093257fe5b6001600160a01b0390921660209283029190910190910152600101610906565b50805b82518110156109a057838282038151811061096c57fe5b602002602001015183828151811061098057fe5b6001600160a01b0390921660209283029190910190910152600101610955565b506109a96119e4565b5060408051610180810182526001600160a01b038089168252868116602080840191909152610120808c015160ff16848601528b51606085015260025483166080850152908b01805160a085015260c0840187905260e0808d015184169085015291891661010084015260009083018190526101408301819052610160830152519151909133917f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d991610a5e918b91906120a8565b60405180910390a2336001600160a01b03167f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d98785604051610aa19291906120a8565b60405180910390a26005546040517f8a754bbe0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690638a754bbe90610af2908490600401612542565b600060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050505050505050915091565b6004546001600160a01b031681565b6001546001600160a01b031681565b6000818152602081905260409020600201545b919050565b600082815260208190526040902060020154610b82906103176113a8565b610b9e5760405162461bcd60e51b815260040161051090612284565b610ba882826113ac565b5050565b6005546001600160a01b031681565b610bc36113a8565b6001600160a01b0316816001600160a01b031614610bf35760405162461bcd60e51b8152600401610510906124e5565b610ba88282611415565b6003546001600160a01b031681565b7f506f6f6c5265676973747279000000000000000000000000000000000000000081565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6000610c5f8261147e565b9050816001600160a01b03167f3bf919a220a0f12ddcaf77fd06ffa4b9c728617774936f0d78b452010319c82482604051610c9a919061207a565b60405180910390a2919050565b6000828152602081905260408120610cbf9083611504565b90505b92915050565b6000828152602081905260408120610cbf9083611510565b610d0a7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b610d265760405162461bcd60e51b81526004016105109061234f565b610d2f81611525565b50565b600081565b610d607f00000000000000000000000000000000000000000000000000000000000000006115ad565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b60055481516040517f5b506a000000000000000000000000000000000000000000000000000000000081526000926001600160a01b031691635b506a0091610dd191906004016121e8565b602060405180830381600087803b158015610deb57600080fd5b505af1158015610dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e239190611f05565b15610e405760405162461bcd60e51b8152600401610510906122e1565b600254600090610e58906001600160a01b0316610c54565b9050806001600160a01b031663b28cb6dc846020015185604001516040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525087606001516040518060400160405280600981526020017f204c5020546f6b656e0000000000000000000000000000000000000000000000815250604051602001610ef693929190612037565b60408051601f1981840301815290829052606089015160808a015160a08b015160c08c01516001547fffffffff0000000000000000000000000000000000000000000000000000000060e08b901b168752610f619897966001600160a01b03909116906004016120d2565b600060405180830381600087803b158015610f7b57600080fd5b505af1158015610f8f573d6000803e3d6000fd5b50505060e08401516040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b038416925063f2fde38b91610fdb9160040161207a565b600060405180830381600087803b158015610ff557600080fd5b505af1158015611009573d6000803e3d6000fd5b505050506000816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561104857600080fd5b505afa15801561105c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110809190611f1d565b96505050505050506110906119e4565b5060408051610180810182526001600160a01b0384811682528381166020808401919091526101008881015160ff1684860152885160608501526002549092166080840152878101805160a085015284516000808252928101865260c085015260e0840182905291830181905261012083018190526101408301819052610160830152519151909133917f0838512b7934222cec571cf3fde1cf3e9e864bbc431bd5d1ef4d9ed3079093d991611148918791906120a8565b60405180910390a26005546040517f8a754bbe0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690638a754bbe90611199908490600401612542565b600060405180830381600087803b1580156111b357600080fd5b505af11580156111c7573d6000803e3d6000fd5b5094979650505050505050565b6040518060400160405280600981526020017f204c5020546f6b656e000000000000000000000000000000000000000000000081525081565b6040518060400160405280600781526020017f536164646c65200000000000000000000000000000000000000000000000000081525081565b6112707fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61128c5760405162461bcd60e51b81526004016105109061234f565b610d2f8161169d565b6000818152602081905260408120610cc290611725565b6002546001600160a01b031681565b6000828152602081905260409020600201546112d9906103176113a8565b610bf35760405162461bcd60e51b815260040161051090612386565b61131f7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61133b5760405162461bcd60e51b81526004016105109061234f565b610d2f81611730565b61136e7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33610cc8565b61138a5760405162461bcd60e51b81526004016105109061234f565b610d2f816117b8565b6000610cbf836001600160a01b038416611840565b3390565b60008281526020819052604090206113c49082611393565b15610ba8576113d16113a8565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260208190526040902061142d908261188a565b15610ba85761143a6113a8565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610b5f5760405162461bcd60e51b8152600401610510906123e3565b6000610cbf838361189f565b6000610cbf836001600160a01b0384166118e4565b6001600160a01b03811661154b5760405162461bcd60e51b815260040161051090612451565b600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f768ccdac0361ba56b697aa598fdd415f51a59d121b9d2b50714d3072cc4a8f1790600090a250565b6040517f3705f6250000000000000000000000000000000000000000000000000000000081526001600160a01b03821690633705f62590611612907f506f6f6c52656769737472790000000000000000000000000000000000000000906004016121e8565b60206040518083038186803b15801561162a57600080fd5b505afa15801561163e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116629190611bd7565b600580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b6001600160a01b0381166116c35760405162461bcd60e51b8152600401610510906124ae565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f06fc5602fc767cbb172d176a4cd0531d747abbdd090065ebd7b63ee4d2f0b44d90600090a250565b6000610cc2826118fc565b6001600160a01b0381166117565760405162461bcd60e51b81526004016105109061241a565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f6c149d1850b03102a8ac77fc865c12f017f4fb8bf9f9af345d36b0e8b60bcc8590600090a250565b6001600160a01b0381166117de5760405162461bcd60e51b815260040161051090612318565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f336ea638298c0cea1e72c71ed04716bef23a7a6251478299d7ca4067fea0c47990600090a250565b600061184c83836118e4565b61188257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cc2565b506000610cc2565b6000610cbf836001600160a01b038416611900565b815460009082106118c25760405162461bcd60e51b815260040161051090612227565b8260000182815481106118d157fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156119da5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808301919081019060009087908390811061195157fe5b906000526020600020015490508087600001848154811061196e57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061199e57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610cc2565b6000915050610cc2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8035610cc2816126b7565b600082601f830112611a62578081fd5b8135611a75611a7082612667565b612640565b818152915060208083019084810181840286018201871015611a9657600080fd5b60005b84811015611abe578135611aac816126b7565b84529282019290820190600101611a99565b505050505092915050565b600082601f830112611ad9578081fd5b8135611ae7611a7082612667565b818152915060208083019084810181840286018201871015611b0857600080fd5b60005b84811015611abe57611b1d8883611ba3565b84529282019290820190600101611b0b565b8051610cc2816126b7565b600082601f830112611b4a578081fd5b813567ffffffffffffffff811115611b60578182fd5b611b736020601f19601f84011601612640565b9150808252836020828501011115611b8a57600080fd5b8060208401602084013760009082016020015292915050565b803560ff81168114610cc257600080fd5b600060208284031215611bc5578081fd5b8135611bd0816126b7565b9392505050565b600060208284031215611be8578081fd5b8151611bd0816126b7565b60006020808385031215611c05578182fd5b825167ffffffffffffffff811115611c1b578283fd5b8301601f81018513611c2b578283fd5b8051611c39611a7082612667565b8181528381019083850185840285018601891015611c55578687fd5b8694505b83851015611c7f57611c6b8982611b2f565b835260019490940193918501918501611c59565b50979650505050505050565b600060208284031215611c9c578081fd5b5035919050565b60008060408385031215611cb5578081fd5b823591506020830135611cc7816126b7565b809150509250929050565b60008060408385031215611ce4578182fd5b50508035926020909101359150565b600060208284031215611d04578081fd5b813567ffffffffffffffff80821115611d1b578283fd5b8184019150610140808387031215611d31578384fd5b611d3a81612640565b905082358152602083013582811115611d51578485fd5b611d5d87828601611a52565b602083015250604083013582811115611d74578485fd5b611d8087828601611ac9565b604083015250606083013582811115611d97578485fd5b611da387828601611b3a565b6060830152506080830135608082015260a083013560a082015260c083013560c0820152611dd48660e08501611a47565b60e08201526101009150611dea86838501611a47565b828201526101209150611dff86838501611ba3565b91810191909152949350505050565b600060208284031215611e1f578081fd5b813567ffffffffffffffff80821115611e36578283fd5b8184019150610120808387031215611e4c578384fd5b611e5581612640565b905082358152602083013582811115611e6c578485fd5b611e7887828601611a52565b602083015250604083013582811115611e8f578485fd5b611e9b87828601611ac9565b604083015250606083013582811115611eb2578485fd5b611ebe87828601611b3a565b6060830152506080830135608082015260a083013560a082015260c083013560c0820152611eef8660e08501611a47565b60e08201526101009150611dff86838501611ba3565b600060208284031215611f16578081fd5b5051919050565b600080600080600080600060e0888a031215611f37578283fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c0880151611f6c816126b7565b8091505092959891949750929550565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015611fc15781516001600160a01b031687529582019590820190600101611f9c565b509495945050505050565b6000815180845260208085019450808401835b83811015611fc157815160ff1687529582019590820190600101611fdf565b15159052565b6000815180845261201c816020860160208601612687565b601f01601f19169290920160200192915050565b60ff169052565b60008451612049818460208901612687565b84519083019061205d818360208901612687565b8451910190612070818360208801612687565b0195945050505050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b60006001600160a01b0384168252604060208301526120ca6040830184611f89565b949350505050565b60006101008083526120e68184018c611f89565b905082810360208401526120fa818b611fcc565b9050828103604084015261210e818a612004565b905082810360608401526121228189612004565b9150508560808301528460a08301528360c08301526001600160a01b03831660e08301529998505050505050505050565b60006101208083526121678184018d611f89565b9050828103602084015261217b818c611fcc565b9050828103604084015261218f818b612004565b905082810360608401526121a3818a612004565b6080840198909852505060a081019490945260c08401929092526001600160a01b0390811660e08401521661010090910152949350505050565b901515815260200190565b90815260200190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b600060208252610cbf6020830184612004565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b60208082526018908201527f706f6f6c206e616d6520616c7265616479206578697374730000000000000000604082015260600190565b6020808252601a908201527f546172676574204c50546f6b656e2063616e6e6f742062652030000000000000604082015260600190565b6020808252600c908201527f6f6e6c79206d616e616765720000000000000000000000000000000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b60208082526016908201527f455243313136373a20637265617465206661696c656400000000000000000000604082015260600190565b60208082526017908201527f54617267657420537761702063616e6e6f742062652030000000000000000000604082015260600190565b60208082526022908201527f546172676574204d657461537761704465706f7369742063616e6e6f7420626560408201527f2030000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f546172676574204d657461537761702063616e6e6f7420626520300000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252612556602083018451611f7c565b60208301516125686040840182611f7c565b50604083015161257b6060840182612030565b5060608301516080830152608083015161259860a0840182611f7c565b5060a08301516101808060c08501526125b56101a0850183611f89565b915060c0850151601f198584030160e08601526125d28382611f89565b92505060e08501516101006125e981870183611f7c565b86015190506101206125fd86820183611f7c565b860151905061014061261186820183611ffe565b860151905061016061262586820183611ffe565b860151905061263685830182611ffe565b5090949350505050565b60405181810167ffffffffffffffff8111828210171561265f57600080fd5b604052919050565b600067ffffffffffffffff82111561267d578081fd5b5060209081020190565b60005b838110156126a257818101518382015260200161268a565b838111156126b1576000848401525b50505050565b6001600160a01b0381168114610d2f57600080fdfea2646970667358221220d56422b9e463c0dcb41b8cca0dcd51818946ab0781666fb5f3badcc92cb3841564736f6c634300060c0033", + "devdoc": { + "events": { + "NewSwapPool(address,address,address[])": { + "params": { + "deployer": "address of the deployer", + "pooledTokens": ", array of addresses of the tokens in the pool", + "swapAddress": "address of the deployed pool" + } + }, + "PoolRegistryUpdated(address)": { + "params": { + "poolRegistry": "address of the current Saddle Pool Registry" + } + } + }, + "kind": "dev", + "methods": { + "clone(address)": { + "params": { + "target": "the address of the target pool to be cloned" + }, + "returns": { + "newClone": "an address of the cloned pool" + } + }, + "deployMetaSwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,address,uint8))": { + "params": { + "input": ", a DeployMetaSwapInput struct containing the input parameters for the meta pool." + } + }, + "deploySwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,uint8))": { + "params": { + "input": ", a struct containing the input parameters for the pool to be deployed, must include a unique pool name." + }, + "returns": { + "deployedSwap": "the address of the deployed pool." + } + }, + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`." + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role." + } + }, + "title": "PermissionlessDeployer", + "version": 1 + }, + "userdoc": { + "events": { + "NewSwapPool(address,address,address[])": { + "notice": "Emmited when a new pool is deployed" + }, + "PoolRegistryUpdated(address)": { + "notice": "Emmited when the pool registry cache is updated" + } + }, + "kind": "user", + "methods": { + "SADDLE_MANAGER_ROLE()": { + "notice": "Role responsible for managing target addresses" + }, + "clone(address)": { + "notice": "Uses openzeppelin's clone mechanism to clone an existing a pool for cheaper deployments." + }, + "deployMetaSwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,address,uint8))": { + "notice": "Deploys a new meta pool." + }, + "deploySwap((bytes32,address[],uint8[],string,uint256,uint256,uint256,address,uint8))": { + "notice": "Deploys a new pool, adds an entry in the Saddle Pool Registry." + }, + "updatePoolRegistryCache()": { + "notice": "Updates cached address of the pool registry **should be onlymanager?" + } + }, + "notice": "Allows for anyone to indepentantly deploy pools and meta pools of given tokens. A user will set custom parameters for the pool such as the trading/admin fees, as well as the a-parameter. Ownership of the pools are given to the deploying address. Saddle will collect 50% of the trading fees earned by the pool.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1726, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)" + }, + { + "astId": 31861, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "targetLPToken", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 31863, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "targetSwap", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 31865, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "targetMetaSwap", + "offset": 0, + "slot": "3", + "type": "t_address" + }, + { + "astId": 31867, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "targetMetaSwapDeposit", + "offset": 0, + "slot": "4", + "type": "t_address" + }, + { + "astId": 31875, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "poolRegistryCached", + "offset": 0, + "slot": "5", + "type": "t_contract(IPoolRegistry)25070" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "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_contract(IPoolRegistry)25070": { + "encoding": "inplace", + "label": "contract IPoolRegistry", + "numberOfBytes": "20" + }, + "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)1722_storage" + }, + "t_mapping(t_bytes32,t_uint256)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_struct(AddressSet)5815_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 5814, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)5550_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(RoleData)1722_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 1719, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_struct(AddressSet)5815_storage" + }, + { + "astId": 1721, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "adminRole", + "offset": 0, + "slot": "2", + "type": "t_bytes32" + } + ], + "numberOfBytes": "96" + }, + "t_struct(Set)5550_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 5545, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 5549, + "contract": "contracts/permissionless/PermissionlessDeployer.sol:PermissionlessDeployer", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} diff --git a/deployments/base_testnet/PermissionlessMetaSwapV1.json b/deployments/base_testnet/PermissionlessMetaSwapV1.json new file mode 100644 index 00000000..b501d180 --- /dev/null +++ b/deployments/base_testnet/PermissionlessMetaSwapV1.json @@ -0,0 +1,1770 @@ +{ + "address": "0xe280EFE654328a3325fc5A9EAb8E998D418C86FB", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IMasterRegistry", + "name": "_masterRegistry", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "AddLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "NewSwapFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newWithdrawFee", + "type": "uint256" + } + ], + "name": "NewWithdrawFee", + "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": "uint256", + "name": "oldA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "initialTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "RampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidityImbalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "boughtId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + } + ], + "name": "RemoveLiquidityOne", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "StopRampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwapUnderlying", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "FEE_COLLECTOR_NAME", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MASTER_REGISTRY", + "outputs": [ + { + "internalType": "contract IMasterRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "minToMint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "calculateRemoveLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + } + ], + "name": "calculateRemoveLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + } + ], + "name": "calculateSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + } + ], + "name": "calculateSwapUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "calculateTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeCollector", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getA", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAPrecise", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAdminBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getTokenBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "name": "getTokenIndex", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVirtualPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "_pooledTokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "lpTokenTargetAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "_pooledTokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "lpTokenTargetAddress", + "type": "address" + }, + { + "internalType": "contract ISwap", + "name": "baseSwap", + "type": "address" + } + ], + "name": "initializeMetaSwap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "metaSwapStorage", + "outputs": [ + { + "internalType": "contract ISwap", + "name": "baseSwap", + "type": "address" + }, + { + "internalType": "uint256", + "name": "baseVirtualPrice", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseCacheLastUpdated", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "rampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxBurnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityImbalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "minAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "setAdminFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "setSwapFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "stopRampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minDy", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "swapStorage", + "outputs": [ + { + "internalType": "uint256", + "name": "initialA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "contract LPToken", + "name": "lpToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minDy", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateFeeCollectorCache", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAdminFees", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x1e34f2c0926b512a9b645005a33da93f981e5a9c8aca19a6e7dea455bdef6a7e", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xe280EFE654328a3325fc5A9EAb8E998D418C86FB", + "transactionIndex": 3, + "gasUsed": "4004785", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xf0b5658b40441d356dc2f4a6fc47578573890fc245564e0a51d94c45bbf8d482", + "transactionHash": "0x1e34f2c0926b512a9b645005a33da93f981e5a9c8aca19a6e7dea455bdef6a7e", + "logs": [], + "blockNumber": 2717073, + "cumulativeGasUsed": "4125785", + "status": 1, + "byzantium": true + }, + "args": ["0x9cDeF6e33687F438808766fC133b2E9d1A16AD57"], + "numDeployments": 1, + "solcInputHash": "bc3a64a5cffb1e8de0dbf9fb306e4f9f", + "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IMasterRegistry\",\"name\":\"_masterRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"NewSwapFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newWithdrawFee\",\"type\":\"uint256\"}],\"name\":\"NewWithdrawFee\",\"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\":\"uint256\",\"name\":\"oldA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialTime\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"RampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityImbalance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"boughtId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityOne\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"currentA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"}],\"name\":\"StopRampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwap\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwapUnderlying\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FEE_COLLECTOR_NAME\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MASTER_REGISTRY\",\"outputs\":[{\"internalType\":\"contract IMasterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"minToMint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateRemoveLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"}],\"name\":\"calculateRemoveLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"}],\"name\":\"calculateSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"}],\"name\":\"calculateSwapUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"calculateTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeCollector\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPrecise\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getAdminBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getTokenBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"}],\"name\":\"getTokenIndex\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVirtualPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"_pooledTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"lpTokenTargetAddress\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"_pooledTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"lpTokenTargetAddress\",\"type\":\"address\"},{\"internalType\":\"contract ISwap\",\"name\":\"baseSwap\",\"type\":\"address\"}],\"name\":\"initializeMetaSwap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"metaSwapStorage\",\"outputs\":[{\"internalType\":\"contract ISwap\",\"name\":\"baseSwap\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"baseVirtualPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"baseCacheLastUpdated\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"rampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"minAmounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"maxBurnAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityImbalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"minAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"setAdminFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"setSwapFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stopRampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDy\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapStorage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"initialA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initialATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"contract LPToken\",\"name\":\"lpToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDy\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"swapUnderlying\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateFeeCollectorCache\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawAdminFees\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's deployment size.\",\"kind\":\"dev\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"deadline\":\"latest timestamp to accept this transaction\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation\"},\"returns\":{\"_0\":\"amount of LP token user minted and received\"}},\"calculateRemoveLiquidity(uint256)\":{\"params\":{\"amount\":\"the amount of LP tokens that would be burned on withdrawal\"},\"returns\":{\"_0\":\"array of token balances that the user will receive\"}},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"params\":{\"tokenAmount\":\"the amount of LP token to burn\",\"tokenIndex\":\"index of which token will be withdrawn\"},\"returns\":{\"_0\":\"availableTokenAmount calculated amount of underlying token available to withdraw\"}},\"calculateSwap(uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of tokens the user will receive\"}},\"calculateSwapUnderlying(uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of tokens the user will receive\"}},\"calculateTokenAmount(uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\"},\"returns\":{\"_0\":\"token amount the user will receive\"}},\"constructor\":{\"params\":{\"_masterRegistry\":\"address of the MasterRegistry contract\"}},\"getA()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter\"}},\"getAPrecise()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter in its raw precision form\"}},\"getAdminBalance(uint256)\":{\"params\":{\"index\":\"Index of the pooled token\"},\"returns\":{\"_0\":\"admin's token balance in the token's precision\"}},\"getToken(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"address of the token at given index\"}},\"getTokenBalance(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"current balance of the pooled token at given index with token's native precision\"}},\"getTokenIndex(address)\":{\"params\":{\"tokenAddress\":\"address of the token\"},\"returns\":{\"_0\":\"the index of the given token address\"}},\"getVirtualPrice()\":{\"returns\":{\"_0\":\"the virtual price, scaled to the POOL_PRECISION_DECIMALS\"}},\"initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)\":{\"params\":{\"_a\":\"the amplification coefficient * n * (n - 1). See the StableSwap paper for details\",\"_adminFee\":\"default adminFee to be initialized with\",\"_fee\":\"default swap fee to be initialized with\",\"_pooledTokens\":\"an array of ERC20s this pool will accept\",\"decimals\":\"the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\",\"lpTokenName\":\"the long-form name of the token to be deployed\",\"lpTokenSymbol\":\"the short symbol for the token to be deployed\"}},\"initializeMetaSwap(address[],uint8[],string,string,uint256,uint256,uint256,address,address)\":{\"params\":{\"_a\":\"the amplification coefficient * n * (n - 1). See the StableSwap paper for details\",\"_adminFee\":\"default adminFee to be initialized with\",\"_fee\":\"default swap fee to be initialized with\",\"_pooledTokens\":\"an array of ERC20s this pool will accept. The last element must be an existing Swap pool's LP token's address.\",\"decimals\":\"the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\",\"lpTokenName\":\"the long-form name of the token to be deployed\",\"lpTokenSymbol\":\"the short symbol for the token to be deployed\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"rampA(uint256,uint256)\":{\"params\":{\"futureA\":\"the new A to ramp towards\",\"futureTime\":\"timestamp when the new A should be reached\"}},\"removeLiquidity(uint256,uint256[],uint256)\":{\"details\":\"Liquidity can always be removed, even when the pool is paused.\",\"params\":{\"amount\":\"the amount of LP tokens to burn\",\"deadline\":\"latest timestamp to accept this transaction\",\"minAmounts\":\"the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation\"},\"returns\":{\"_0\":\"amounts of tokens user received\"}},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"deadline\":\"latest timestamp to accept this transaction\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\"},\"returns\":{\"_0\":\"amount of LP tokens burned\"}},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"tokenAmount\":\"the amount of the token you want to receive\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount of chosen token user received\"}},\"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.\"},\"setAdminFee(uint256)\":{\"params\":{\"newAdminFee\":\"new admin fee to be applied on future transactions\"}},\"setSwapFee(uint256)\":{\"params\":{\"newSwapFee\":\"new swap fee to be applied on future transactions\"}},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"dx\":\"the amount of tokens the user wants to swap from\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"tokenIndexFrom\":\"the token the user wants to swap from\",\"tokenIndexTo\":\"the token the user wants to swap to\"}},\"swapUnderlying(uint8,uint8,uint256,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"dx\":\"the amount of tokens the user wants to swap from\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"tokenIndexFrom\":\"the token the user wants to swap from\",\"tokenIndexTo\":\"the token the user wants to swap to\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"MetaSwap - A StableSwap implementation in solidity.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"notice\":\"Add liquidity to the pool with the given amounts of tokens\"},\"calculateRemoveLiquidity(uint256)\":{\"notice\":\"A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens\"},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"notice\":\"Calculate the amount of underlying token available to withdraw when withdrawing via only single token\"},\"calculateSwap(uint8,uint8,uint256)\":{\"notice\":\"Calculate amount of tokens you receive on swap\"},\"calculateSwapUnderlying(uint8,uint8,uint256)\":{\"notice\":\"Calculate amount of tokens you receive on swap. For this function, the token indices are flattened out so that underlying tokens are represented.\"},\"calculateTokenAmount(uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running\"},\"constructor\":\"Constructor for the PermissionlessSwap contract.\",\"getA()\":{\"notice\":\"Return A, the amplification coefficient * n * (n - 1)\"},\"getAPrecise()\":{\"notice\":\"Return A in its raw precision form\"},\"getAdminBalance(uint256)\":{\"notice\":\"This function reads the accumulated amount of admin fees of the token with given index\"},\"getToken(uint8)\":{\"notice\":\"Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\"},\"getTokenBalance(uint8)\":{\"notice\":\"Return current balance of the pooled token at given index\"},\"getTokenIndex(address)\":{\"notice\":\"Return the index of the given token address. Reverts if no matching token is found.\"},\"getVirtualPrice()\":{\"notice\":\"Get the virtual price, to help calculate profit\"},\"initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)\":{\"notice\":\"This overrides Swap's initialize function to prevent initializing without the address of the base Swap contract.\"},\"initializeMetaSwap(address[],uint8[],string,string,uint256,uint256,uint256,address,address)\":{\"notice\":\"Initializes this MetaSwap contract with the given parameters. MetaSwap uses an existing Swap pool to expand the available liquidity. _pooledTokens array should contain the base Swap pool's LP token as the last element. For example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] as _pooledTokens. This will also deploy the LPToken that represents users' LP position. The owner of LPToken will be this contract - which means only this contract is allowed to mint new tokens.\"},\"pause()\":{\"notice\":\"Pause the contract. Revert if already paused.\"},\"rampA(uint256,uint256)\":{\"notice\":\"Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range.\"},\"removeLiquidity(uint256,uint256[],uint256)\":{\"notice\":\"Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"setAdminFee(uint256)\":{\"notice\":\"Update the admin fee. Admin fee takes portion of the swap fee.\"},\"setSwapFee(uint256)\":{\"notice\":\"Update the swap fee to be applied on swaps\"},\"stopRampA()\":{\"notice\":\"Stop ramping A immediately. Reverts if ramp A is already stopped.\"},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"notice\":\"Swap two tokens using this pool\"},\"swapUnderlying(uint8,uint8,uint256,uint256,uint256)\":{\"notice\":\"Swap two tokens using this pool and the base pool.\"},\"unpause()\":{\"notice\":\"Unpause the contract. Revert if already unpaused.\"},\"updateFeeCollectorCache()\":{\"notice\":\"Updates cached address of the fee collector\"},\"withdrawAdminFees()\":{\"notice\":\"Withdraw all admin fees to the contract owner and the fee collector\"}},\"notice\":\"This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws. MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens. As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD. Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case, `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/permissionless/PermissionlessMetaSwap.sol\":\"PermissionlessMetaSwap\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/Initializable.sol\\\";\\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 initializer {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal initializer {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xb419e68addcb82ecda3ad3974b0d2db76435ce9b08435a04d5b119a0c5d45ea5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMathUpgradeable {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x0dd1e9b19801e3e7d900fbf4182d81e1afd23ad7be39504e33df6bbcba91d724\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-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 */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd8e4eb08dcc1d1860fb347ba5ffd595242b9a1b66d49a47f2b4cb51c3f35017e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./ERC20Upgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal initializer {\\n __Context_init_unchained();\\n __ERC20Burnable_init_unchained();\\n }\\n\\n function __ERC20Burnable_init_unchained() internal initializer {\\n }\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \\\"ERC20: burn amount exceeds allowance\\\");\\n\\n _approve(account, _msgSender(), decreasedAllowance);\\n _burn(account, amount);\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xd0359e87fe2618573f49a95e13d9dbc31521ad64526b135618abb2a2dc362fbe\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"../../math/SafeMathUpgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n uint256[44] private __gap;\\n}\\n\",\"keccak256\":\"0x506dd0718f9ace50588c13848167df5e04ae16abb56341afb10c31ff149bc79b\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xa1931c47a617014f858580db625aa0dcf343796f39acd4b5b51effc092a1f0a9\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary 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 function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfc5ea91fa9ceb1961023b2a6c978b902888c52b90847ac7813fe3b79524165f6\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/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 GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal initializer {\\n __Context_init_unchained();\\n }\\n\\n function __Context_init_unchained() internal initializer {\\n }\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xbbf8a21b9a66c48d45ff771b8563c6df19ba451d63dfb8380a865c1e1f29d1a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/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 initializer {\\n __Context_init_unchained();\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal initializer {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n require(!paused(), \\\"Pausable: paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n require(paused(), \\\"Pausable: not paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x73bef0a5dec3efde8183c4858d90f683ed2771656c4329647b4d5b0f89498fd5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuardUpgradeable is Initializable {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n function __ReentrancyGuard_init() internal initializer {\\n __ReentrancyGuard_init_unchained();\\n }\\n\\n function __ReentrancyGuard_init_unchained() internal initializer {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x46034cd5cca740f636345c8f7aebae0f78adfd4b70e31e6f888cccbe1086586e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xcc78a17dd88fa5a2edc60c8489e2f405c0913b377216a5b26b35656b2d0dab52\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address master) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `master` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\\n return predictDeterministicAddress(master, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0x0d24348f536f928d8b42789737bf34762faee065667ab530ea20969a9d9920d1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) public {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0xca0c2396dbeb3503b51abf4248ebf77a1461edad513c01529df51850a012bee3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.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 SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) 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(IERC20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require((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(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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) { // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf12dfbe97e6276980b83d2830bb0eb75e0cf4f3e626c2471137f82158ae6a0fc\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"contracts/AmplificationUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"./SwapUtils.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtils.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtils {\\n using SafeMath for uint256;\\n\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtils.Swap storage self) external view returns (uint256) {\\n return _getAPrecise(self).div(A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtils.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtils.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return\\n a0.add(\\n a1.sub(a0).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\\n );\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return\\n a0.sub(\\n a0.sub(a1).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\\n );\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtils.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= self.initialATime.add(1 days),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= block.timestamp.add(MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_.mul(A_PRECISION);\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n futureAPrecise.mul(MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= initialAPrecise.mul(MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtils.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0x454f7c599a980fc449ff0f21dee10922262193134ea709f3be50c9d44a7d5385\",\"license\":\"MIT\"},\"contracts/LPToken.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwap.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPToken is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8b16a37e14fd2d387dac20bf1773522b7667402f27a4b301617b928d7b998ac5\",\"license\":\"MIT\"},\"contracts/MathUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtils {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x455c798b26b679dff11a4ad5d52f7fef85c42d403bd430da443948f65cf000a0\",\"license\":\"MIT\"},\"contracts/OwnerPausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\\\";\\n\\n/**\\n * @title OwnerPausable\\n * @notice An ownable contract allows the owner to pause and unpause the\\n * contract without a delay.\\n * @dev Only methods using the provided modifiers will be paused.\\n */\\nabstract contract OwnerPausableUpgradeable is\\n OwnableUpgradeable,\\n PausableUpgradeable\\n{\\n function __OwnerPausable_init() internal initializer {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n __Pausable_init_unchained();\\n }\\n\\n /**\\n * @notice Pause the contract. Revert if already paused.\\n */\\n function pause() external onlyOwner {\\n PausableUpgradeable._pause();\\n }\\n\\n /**\\n * @notice Unpause the contract. Revert if already unpaused.\\n */\\n function unpause() external onlyOwner {\\n PausableUpgradeable._unpause();\\n }\\n}\\n\",\"keccak256\":\"0xe8d79072ff7e9ec0ade50d81be8681a9fedfabe7b3d3de116e83cb7f4e1446f6\",\"license\":\"MIT\"},\"contracts/Swap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/Clones.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\\\";\\nimport \\\"./OwnerPausableUpgradeable.sol\\\";\\nimport \\\"./SwapUtils.sol\\\";\\nimport \\\"./AmplificationUtils.sol\\\";\\n\\n/**\\n * @title Swap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\\n * deployment size.\\n */\\ncontract Swap is OwnerPausableUpgradeable, ReentrancyGuardUpgradeable {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n using SwapUtils for SwapUtils.Swap;\\n using AmplificationUtils for SwapUtils.Swap;\\n\\n // Struct storing data responsible for automatic market maker functionalities. In order to\\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtils.sol\\n SwapUtils.Swap public swapStorage;\\n\\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\\n // getTokenIndex function also relies on this mapping to retrieve token index.\\n mapping(address => uint8) private tokenIndexes;\\n\\n /*** EVENTS ***/\\n\\n // events replicated from SwapUtils to make the ABI easier for dumb\\n // clients\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n event NewWithdrawFee(uint256 newWithdrawFee);\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n /**\\n * @notice Initializes this Swap contract with the given parameters.\\n * This will also clone a LPToken contract that represents users'\\n * LP positions. The owner of LPToken will be this contract - which means\\n * only this contract is allowed to mint/burn tokens.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual initializer {\\n __OwnerPausable_init();\\n __ReentrancyGuard_init();\\n // Check _pooledTokens and precisions parameter\\n require(_pooledTokens.length > 1, \\\"_pooledTokens.length <= 1\\\");\\n require(_pooledTokens.length <= 32, \\\"_pooledTokens.length > 32\\\");\\n require(\\n _pooledTokens.length == decimals.length,\\n \\\"_pooledTokens decimals mismatch\\\"\\n );\\n\\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\\n\\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\\n if (i > 0) {\\n // Check if index is already used. Check if 0th element is a duplicate.\\n require(\\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\\n _pooledTokens[0] != _pooledTokens[i],\\n \\\"Duplicate tokens\\\"\\n );\\n }\\n require(\\n address(_pooledTokens[i]) != address(0),\\n \\\"The 0 address isn't an ERC-20\\\"\\n );\\n require(\\n decimals[i] <= SwapUtils.POOL_PRECISION_DECIMALS,\\n \\\"Token decimals exceeds max\\\"\\n );\\n precisionMultipliers[i] =\\n 10 **\\n uint256(SwapUtils.POOL_PRECISION_DECIMALS).sub(\\n uint256(decimals[i])\\n );\\n tokenIndexes[address(_pooledTokens[i])] = i;\\n }\\n\\n // Check _a, _fee, _adminFee, _withdrawFee parameters\\n require(_a < AmplificationUtils.MAX_A, \\\"_a exceeds maximum\\\");\\n require(_fee < SwapUtils.MAX_SWAP_FEE, \\\"_fee exceeds maximum\\\");\\n require(\\n _adminFee < SwapUtils.MAX_ADMIN_FEE,\\n \\\"_adminFee exceeds maximum\\\"\\n );\\n\\n // Clone and initialize a LPToken contract\\n LPToken lpToken = LPToken(Clones.clone(lpTokenTargetAddress));\\n require(\\n lpToken.initialize(lpTokenName, lpTokenSymbol),\\n \\\"could not init lpToken clone\\\"\\n );\\n\\n // Initialize swapStorage struct\\n swapStorage.lpToken = lpToken;\\n swapStorage.pooledTokens = _pooledTokens;\\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\\n swapStorage.balances = new uint256[](_pooledTokens.length);\\n swapStorage.initialA = _a.mul(AmplificationUtils.A_PRECISION);\\n swapStorage.futureA = _a.mul(AmplificationUtils.A_PRECISION);\\n // swapStorage.initialATime = 0;\\n // swapStorage.futureATime = 0;\\n swapStorage.swapFee = _fee;\\n swapStorage.adminFee = _adminFee;\\n }\\n\\n /*** MODIFIERS ***/\\n\\n /**\\n * @notice Modifier to check deadline against current timestamp\\n * @param deadline latest timestamp to accept this transaction\\n */\\n modifier deadlineCheck(uint256 deadline) {\\n require(block.timestamp <= deadline, \\\"Deadline not met\\\");\\n _;\\n }\\n\\n /*** VIEW FUNCTIONS ***/\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @return A parameter\\n */\\n function getA() external view virtual returns (uint256) {\\n return swapStorage.getA();\\n }\\n\\n /**\\n * @notice Return A in its raw precision form\\n * @dev See the StableSwap paper for details\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise() external view virtual returns (uint256) {\\n return swapStorage.getAPrecise();\\n }\\n\\n /**\\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\\n * @param index the index of the token\\n * @return address of the token at given index\\n */\\n function getToken(uint8 index) public view virtual returns (IERC20) {\\n require(index < swapStorage.pooledTokens.length, \\\"Out of range\\\");\\n return swapStorage.pooledTokens[index];\\n }\\n\\n /**\\n * @notice Return the index of the given token address. Reverts if no matching\\n * token is found.\\n * @param tokenAddress address of the token\\n * @return the index of the given token address\\n */\\n function getTokenIndex(address tokenAddress)\\n public\\n view\\n virtual\\n returns (uint8)\\n {\\n uint8 index = tokenIndexes[tokenAddress];\\n require(\\n address(getToken(index)) == tokenAddress,\\n \\\"Token does not exist\\\"\\n );\\n return index;\\n }\\n\\n /**\\n * @notice Return current balance of the pooled token at given index\\n * @param index the index of the token\\n * @return current balance of the pooled token at given index with token's native precision\\n */\\n function getTokenBalance(uint8 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n require(index < swapStorage.pooledTokens.length, \\\"Index out of range\\\");\\n return swapStorage.balances[index];\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice() external view virtual returns (uint256) {\\n return swapStorage.getVirtualPrice();\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view virtual returns (uint256) {\\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.calculateTokenAmount(amounts, deposit);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of LP tokens\\n * @param amount the amount of LP tokens that would be burned on withdrawal\\n * @return array of token balances that the user will receive\\n */\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n virtual\\n returns (uint256[] memory)\\n {\\n return swapStorage.calculateRemoveLiquidity(amount);\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view virtual returns (uint256 availableTokenAmount) {\\n return swapStorage.calculateWithdrawOneToken(tokenAmount, tokenIndex);\\n }\\n\\n /**\\n * @notice This function reads the accumulated amount of admin fees of the token with given index\\n * @param index Index of the pooled token\\n * @return admin's token balance in the token's precision\\n */\\n function getAdminBalance(uint256 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.getAdminBalance(index);\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice Swap two tokens using this pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.addLiquidity(amounts, minToMint);\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amounts of tokens user received\\n */\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n deadlineCheck(deadline)\\n returns (uint256[] memory)\\n {\\n return swapStorage.removeLiquidity(amount, minAmounts);\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n swapStorage.removeLiquidityOneToken(\\n tokenAmount,\\n tokenIndex,\\n minAmount\\n );\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\\n }\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner\\n */\\n function withdrawAdminFees() external payable virtual onlyOwner {\\n swapStorage.withdrawAdminFees(owner());\\n }\\n\\n /**\\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(uint256 newAdminFee) external payable onlyOwner {\\n swapStorage.setAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice Update the swap fee to be applied on swaps\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(uint256 newSwapFee) external payable onlyOwner {\\n swapStorage.setSwapFee(newSwapFee);\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param futureA the new A to ramp towards\\n * @param futureTime timestamp when the new A should be reached\\n */\\n function rampA(uint256 futureA, uint256 futureTime)\\n external\\n payable\\n onlyOwner\\n {\\n swapStorage.rampA(futureA, futureTime);\\n }\\n\\n /**\\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\\n */\\n function stopRampA() external payable onlyOwner {\\n swapStorage.stopRampA();\\n }\\n}\\n\",\"keccak256\":\"0x85aed3b11967ea0195717a6777a5e58ee9cc96f94e6992af002720f2b626840b\",\"license\":\"MIT\"},\"contracts/SwapUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtils.sol\\\";\\nimport \\\"./LPToken.sol\\\";\\nimport \\\"./MathUtils.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtils {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n using MathUtils for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPToken lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPToken lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtils._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = currentY\\n .sub(newY)\\n .div(self.tokenPrecisionMultipliers[tokenIndex])\\n .sub(dy);\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] = xpi.sub(\\n (\\n (i == tokenIndex)\\n ? xpi.mul(v.d1).div(v.d0).sub(v.newY)\\n : xpi.sub(xpi.mul(v.d1).div(v.d0))\\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\\n );\\n }\\n\\n uint256 dy = xpReduced[tokenIndex].sub(\\n getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\\n );\\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a.mul(numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s.add(xp[i]);\\n c = c.mul(d).div(xp[i].mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\\n\\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s.add(xp[i]);\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a.mul(numTokens);\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = dP.mul(d).div(xp[j].mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d = nA\\n .mul(s)\\n .div(AmplificationUtils.A_PRECISION)\\n .add(dP.mul(numTokens))\\n .mul(d)\\n .div(\\n nA\\n .sub(AmplificationUtils.A_PRECISION)\\n .mul(d)\\n .div(AmplificationUtils.A_PRECISION)\\n .add(numTokens.add(1).mul(dP))\\n );\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i].mul(precisionMultipliers[i]);\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPToken lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return d.mul(10**uint256(POOL_PRECISION_DECIMALS)).div(supply);\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens.mul(preciseA);\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s.add(_x);\\n c = c.mul(d).div(_x.mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx.mul(multipliers[tokenIndexFrom]).add(xp[tokenIndexFrom]);\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo].sub(y).sub(1);\\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\\n dy = dy.sub(dyFee).div(multipliers[tokenIndexTo]);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = balances[i].mul(amount).div(totalSupply);\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i].add(amounts[i]);\\n } else {\\n balances[i] = balances[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return d1.sub(d0).mul(totalSupply).div(d0);\\n } else {\\n return d0.sub(d1).mul(totalSupply).div(d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)).sub(\\n self.balances[index]\\n );\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return swapFee.mul(numTokens).div(numTokens.sub(1).mul(4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)).sub(beforeBalance);\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\\n self.tokenPrecisionMultipliers[tokenIndexTo]\\n );\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom].add(dx);\\n self.balances[tokenIndexTo] = balances[tokenIndexTo].sub(dy).sub(\\n dyAdminFee\\n );\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\\n beforeBalance\\n );\\n }\\n\\n newBalances[i] = v.balances[i].add(amounts[i]);\\n }\\n\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\\n fees[i] = feePerToken\\n .mul(idealBalance.difference(newBalances[i]))\\n .div(FEE_DENOMINATOR);\\n self.balances[i] = newBalances[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n newBalances[i] = newBalances[i].sub(fees[i]);\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.add(toMint)\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPToken lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i].sub(amounts[i]);\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply.sub(amount));\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPToken lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\\n );\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n balances1[i] = v.balances[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\\n self.balances[i] = balances1[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n balances1[i] = balances1[i].sub(fees[i]);\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount.add(1);\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.sub(tokenAmount)\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)).sub(\\n self.balances[i]\\n );\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0x1571bb987f110239e647da76403b6a73b7a46a082035dc950ddc9db26eb0fbed\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlist.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\ninterface IAllowlist {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xf55e4d678d05bc5d0e24ec5f24504d7437b885e19579f9d29152748c3c1c732e\",\"license\":\"MIT\"},\"contracts/interfaces/IMasterRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\ninterface IMasterRegistry {\\n /* Structs */\\n\\n struct ReverseRegistryData {\\n bytes32 name;\\n uint256 version;\\n }\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param registryName name for the registry\\n * @param registryAddress address of the new registry\\n */\\n function addRegistry(bytes32 registryName, address registryAddress)\\n external\\n payable;\\n\\n /**\\n * @notice Resolves a name to the latest registry address. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToLatestAddress(bytes32 name)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name and version to an address. Reverts if there is no registry with given name and version.\\n * @param name address of the registry you want to resolve to\\n * @param version version of the registry you want to resolve to\\n */\\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name to an array of all addresses. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToAllAddresses(bytes32 name)\\n external\\n view\\n returns (address[] memory);\\n\\n /**\\n * @notice Resolves an address to registry entry data.\\n * @param registryAddress address of a registry you want to resolve\\n * @return name name of the resolved registry\\n * @return version version of the resolved registry\\n * @return isLatest boolean flag of whether the given address is the latest version of the given registries with\\n * matching name\\n */\\n function resolveAddressToRegistryData(address registryAddress)\\n external\\n view\\n returns (\\n bytes32 name,\\n uint256 version,\\n bool isLatest\\n );\\n}\\n\",\"keccak256\":\"0x0e403d7e259003f3826b3009ae3e39344706d7af8a0a5bd48ba45a6ca978226b\",\"license\":\"MIT\"},\"contracts/interfaces/ISwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlist.sol\\\";\\n\\ninterface ISwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlist);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xcd26195c5e3824e7984750a05c9fcb6dde3e266022c3bd1a9dcdda9e967a6f4c\",\"license\":\"MIT\"},\"contracts/meta/MetaSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"../Swap.sol\\\";\\nimport \\\"./MetaSwapUtils.sol\\\";\\n\\n/**\\n * @title MetaSwap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\\n *\\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\\n * deployment size.\\n */\\ncontract MetaSwap is Swap {\\n using MetaSwapUtils for SwapUtils.Swap;\\n\\n MetaSwapUtils.MetaSwap public metaSwapStorage;\\n\\n uint256 constant MAX_UINT256 = 2**256 - 1;\\n\\n /*** EVENTS ***/\\n\\n // events replicated from SwapUtils to make the ABI easier for dumb\\n // clients\\n event TokenSwapUnderlying(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice()\\n external\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n return MetaSwapUtils.getVirtualPrice(swapStorage, metaSwapStorage);\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view virtual override returns (uint256) {\\n return\\n MetaSwapUtils.calculateSwap(\\n swapStorage,\\n metaSwapStorage,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx\\n );\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap. For this function,\\n * the token indices are flattened out so that underlying tokens are represented.\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view virtual returns (uint256) {\\n return\\n MetaSwapUtils.calculateSwapUnderlying(\\n swapStorage,\\n metaSwapStorage,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx\\n );\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n virtual\\n override\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.calculateTokenAmount(\\n swapStorage,\\n metaSwapStorage,\\n amounts,\\n deposit\\n );\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view virtual override returns (uint256) {\\n return\\n MetaSwapUtils.calculateWithdrawOneToken(\\n swapStorage,\\n metaSwapStorage,\\n tokenAmount,\\n tokenIndex\\n );\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice This overrides Swap's initialize function to prevent initializing\\n * without the address of the base Swap contract.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual override initializer {\\n revert(\\\"use initializeMetaSwap() instead\\\");\\n }\\n\\n /**\\n * @notice Initializes this MetaSwap contract with the given parameters.\\n * MetaSwap uses an existing Swap pool to expand the available liquidity.\\n * _pooledTokens array should contain the base Swap pool's LP token as\\n * the last element. For example, if there is a Swap pool consisting of\\n * [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken]\\n * as _pooledTokens.\\n *\\n * This will also deploy the LPToken that represents users'\\n * LP position. The owner of LPToken will be this contract - which means\\n * only this contract is allowed to mint new tokens.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept. The last\\n * element must be an existing Swap pool's LP token's address.\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n */\\n function initializeMetaSwap(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress,\\n ISwap baseSwap\\n ) public payable virtual initializer {\\n Swap.initialize(\\n _pooledTokens,\\n decimals,\\n lpTokenName,\\n lpTokenSymbol,\\n _a,\\n _fee,\\n _adminFee,\\n lpTokenTargetAddress\\n );\\n\\n // MetaSwap initializer\\n metaSwapStorage.baseSwap = baseSwap;\\n metaSwapStorage.baseVirtualPrice = baseSwap.getVirtualPrice();\\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\\n\\n // Read all tokens that belong to baseSwap\\n {\\n uint8 i;\\n for (; i < 32; i++) {\\n try baseSwap.getToken(i) returns (IERC20 token) {\\n metaSwapStorage.baseTokens.push(token);\\n token.safeApprove(address(baseSwap), MAX_UINT256);\\n } catch {\\n break;\\n }\\n }\\n require(i > 1, \\\"baseSwap must pool at least 2 tokens\\\");\\n }\\n\\n // Check the last element of _pooledTokens is owned by baseSwap\\n IERC20 baseLPToken = _pooledTokens[_pooledTokens.length - 1];\\n require(\\n LPToken(address(baseLPToken)).owner() == address(baseSwap),\\n \\\"baseLPToken is not owned by baseSwap\\\"\\n );\\n\\n // Pre-approve the baseLPToken to be used by baseSwap\\n baseLPToken.safeApprove(address(baseSwap), MAX_UINT256);\\n }\\n\\n /**\\n * @notice Swap two tokens using this pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n override\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.swap(\\n swapStorage,\\n metaSwapStorage,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n minDy\\n );\\n }\\n\\n /**\\n * @notice Swap two tokens using this pool and the base pool.\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n )\\n external\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.swapUnderlying(\\n swapStorage,\\n metaSwapStorage,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n minDy\\n );\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n override\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.addLiquidity(\\n swapStorage,\\n metaSwapStorage,\\n amounts,\\n minToMint\\n );\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n override\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.removeLiquidityOneToken(\\n swapStorage,\\n metaSwapStorage,\\n tokenAmount,\\n tokenIndex,\\n minAmount\\n );\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n override\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n MetaSwapUtils.removeLiquidityImbalance(\\n swapStorage,\\n metaSwapStorage,\\n amounts,\\n maxBurnAmount\\n );\\n }\\n}\\n\",\"keccak256\":\"0xfec674874d89d6c8e68de333bfd167363c3e260bec7161659ae94a59a3c2ae69\",\"license\":\"MIT\"},\"contracts/meta/MetaSwapUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"../LPToken.sol\\\";\\nimport \\\"../interfaces/ISwap.sol\\\";\\nimport \\\"../MathUtils.sol\\\";\\nimport \\\"../SwapUtils.sol\\\";\\n\\n/**\\n * @title MetaSwapUtils library\\n * @notice A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities.\\n *\\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created\\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\\n *\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary MetaSwapUtils {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n using MathUtils for uint256;\\n using AmplificationUtils for SwapUtils.Swap;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event TokenSwapUnderlying(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n event NewWithdrawFee(uint256 newWithdrawFee);\\n\\n struct MetaSwap {\\n // Meta-Swap related parameters\\n ISwap baseSwap;\\n uint256 baseVirtualPrice;\\n uint256 baseCacheLastUpdated;\\n IERC20[] baseTokens;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n uint256 xpi;\\n }\\n\\n // Struct storing variables used in calculation in removeLiquidityImbalance function\\n // to avoid stack too deep error\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n LPToken lpToken;\\n uint256 totalSupply;\\n uint256 preciseA;\\n uint256 baseVirtualPrice;\\n uint256[] tokenPrecisionMultipliers;\\n uint256[] newBalances;\\n }\\n\\n struct SwapUnderlyingInfo {\\n uint256 x;\\n uint256 dx;\\n uint256 dy;\\n uint256[] tokenPrecisionMultipliers;\\n uint256[] oldBalances;\\n IERC20[] baseTokens;\\n IERC20 tokenFrom;\\n uint8 metaIndexFrom;\\n IERC20 tokenTo;\\n uint8 metaIndexTo;\\n uint256 baseVirtualPrice;\\n }\\n\\n struct CalculateSwapUnderlyingInfo {\\n uint256 baseVirtualPrice;\\n ISwap baseSwap;\\n uint8 baseLPTokenIndex;\\n uint8 baseTokensLength;\\n uint8 metaIndexTo;\\n uint256 x;\\n uint256 dy;\\n }\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Cache expire time for the stored value of base Swap's virtual price\\n uint256 public constant BASE_CACHE_EXPIRE_TIME = 10 minutes;\\n uint256 public constant BASE_VIRTUAL_PRICE_PRECISION = 10**18;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n /**\\n * @notice Return the stored value of base Swap's virtual price. If\\n * value was updated past BASE_CACHE_EXPIRE_TIME, then read it directly\\n * from the base Swap contract.\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @return base Swap's virtual price\\n */\\n function _getBaseVirtualPrice(MetaSwap storage metaSwapStorage)\\n internal\\n view\\n returns (uint256)\\n {\\n if (\\n block.timestamp >\\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\\n ) {\\n return metaSwapStorage.baseSwap.getVirtualPrice();\\n }\\n return metaSwapStorage.baseVirtualPrice;\\n }\\n\\n function _getBaseSwapFee(ISwap baseSwap)\\n internal\\n view\\n returns (uint256 swapFee)\\n {\\n (, , , , swapFee, , ) = baseSwap.swapStorage();\\n }\\n\\n /**\\n * @notice Calculate how much the user would receive when withdrawing via single token\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @return dy the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n _getBaseVirtualPrice(metaSwapStorage),\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateWithdrawOneToken(\\n SwapUtils.Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 baseVirtualPrice,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 dySwapFee;\\n\\n {\\n uint256 currentY;\\n uint256 newY;\\n\\n // Calculate how much to withdraw\\n (dy, newY, currentY) = _calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n baseVirtualPrice,\\n totalSupply\\n );\\n\\n // Calculate the associated swap fee\\n dySwapFee = currentY\\n .sub(newY)\\n .div(self.tokenPrecisionMultipliers[tokenIndex])\\n .sub(dy);\\n }\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @param baseVirtualPrice the virtual price of the base swap's LP token\\n * @return the dy excluding swap fee, the new y after withdrawing one token, and current y\\n */\\n function _calculateWithdrawOneTokenDY(\\n SwapUtils.Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 baseVirtualPrice,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self, baseVirtualPrice);\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(\\n 0,\\n 0,\\n 0,\\n 0,\\n self._getAPrecise(),\\n 0\\n );\\n v.d0 = SwapUtils.getD(xp, v.preciseA);\\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = SwapUtils.getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = SwapUtils._feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n v.xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] = v.xpi.sub(\\n (\\n (i == tokenIndex)\\n ? v.xpi.mul(v.d1).div(v.d0).sub(v.newY)\\n : v.xpi.sub(v.xpi.mul(v.d1).div(v.d0))\\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\\n );\\n }\\n\\n uint256 dy = xpReduced[tokenIndex].sub(\\n SwapUtils.getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\\n );\\n\\n if (tokenIndex == xp.length.sub(1)) {\\n dy = dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(baseVirtualPrice);\\n v.newY = v.newY.mul(BASE_VIRTUAL_PRICE_PRECISION).div(\\n baseVirtualPrice\\n );\\n xp[tokenIndex] = xp[tokenIndex]\\n .mul(BASE_VIRTUAL_PRICE_PRECISION)\\n .div(baseVirtualPrice);\\n }\\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances. The last element will also get scaled up by\\n * the given baseVirtualPrice.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @param baseVirtualPrice the base virtual price to scale the balance of the\\n * base Swap's LP token.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers,\\n uint256 baseVirtualPrice\\n ) internal pure returns (uint256[] memory) {\\n uint256[] memory xp = SwapUtils._xp(balances, precisionMultipliers);\\n uint256 baseLPTokenIndex = balances.length.sub(1);\\n xp[baseLPTokenIndex] = xp[baseLPTokenIndex].mul(baseVirtualPrice).div(\\n BASE_VIRTUAL_PRICE_PRECISION\\n );\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(SwapUtils.Swap storage self, uint256 baseVirtualPrice)\\n internal\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _xp(\\n self.balances,\\n self.tokenPrecisionMultipliers,\\n baseVirtualPrice\\n );\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @return the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION\\n */\\n function getVirtualPrice(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage\\n ) external view returns (uint256) {\\n uint256 d = SwapUtils.getD(\\n _xp(\\n self.balances,\\n self.tokenPrecisionMultipliers,\\n _getBaseVirtualPrice(metaSwapStorage)\\n ),\\n self._getAPrecise()\\n );\\n uint256 supply = self.lpToken.totalSupply();\\n if (supply != 0) {\\n return d.mul(BASE_VIRTUAL_PRICE_PRECISION).div(supply);\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens. The SwapUtils.Swap storage and\\n * MetaSwap storage should be from the same MetaSwap contract.\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct from the same contract\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n _getBaseVirtualPrice(metaSwapStorage)\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param baseVirtualPrice the virtual price of the base LP token\\n * @return dy the number of tokens the user will get and dyFee the associated fee\\n */\\n function _calculateSwap(\\n SwapUtils.Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 baseVirtualPrice\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory xp = _xp(self, baseVirtualPrice);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 baseLPTokenIndex = xp.length.sub(1);\\n\\n uint256 x = dx.mul(self.tokenPrecisionMultipliers[tokenIndexFrom]);\\n if (tokenIndexFrom == baseLPTokenIndex) {\\n // When swapping from a base Swap token, scale up dx by its virtual price\\n x = x.mul(baseVirtualPrice).div(BASE_VIRTUAL_PRICE_PRECISION);\\n }\\n x = x.add(xp[tokenIndexFrom]);\\n\\n uint256 y = SwapUtils.getY(\\n self._getAPrecise(),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo].sub(y).sub(1);\\n\\n if (tokenIndexTo == baseLPTokenIndex) {\\n // When swapping to a base Swap token, scale down dy by its virtual price\\n dy = dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(baseVirtualPrice);\\n }\\n\\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\\n dy = dy.sub(dyFee);\\n\\n dy = dy.div(self.tokenPrecisionMultipliers[tokenIndexTo]);\\n }\\n\\n /**\\n * @notice Calculates the expected return amount from swapping between\\n * the pooled tokens and the underlying tokens of the base Swap pool.\\n *\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct from the same contract\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwapUnderlying(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256) {\\n CalculateSwapUnderlyingInfo memory v = CalculateSwapUnderlyingInfo(\\n _getBaseVirtualPrice(metaSwapStorage),\\n metaSwapStorage.baseSwap,\\n 0,\\n uint8(metaSwapStorage.baseTokens.length),\\n 0,\\n 0,\\n 0\\n );\\n\\n uint256[] memory xp = _xp(self, v.baseVirtualPrice);\\n v.baseLPTokenIndex = uint8(xp.length.sub(1));\\n {\\n uint8 maxRange = v.baseLPTokenIndex + v.baseTokensLength;\\n require(\\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\\n \\\"Token index out of range\\\"\\n );\\n }\\n\\n if (tokenIndexFrom < v.baseLPTokenIndex) {\\n // tokenFrom is from this pool\\n v.x = xp[tokenIndexFrom].add(\\n dx.mul(self.tokenPrecisionMultipliers[tokenIndexFrom])\\n );\\n } else {\\n // tokenFrom is from the base pool\\n tokenIndexFrom = tokenIndexFrom - v.baseLPTokenIndex;\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n uint256[] memory baseInputs = new uint256[](v.baseTokensLength);\\n baseInputs[tokenIndexFrom] = dx;\\n v.x = v\\n .baseSwap\\n .calculateTokenAmount(baseInputs, true)\\n .mul(v.baseVirtualPrice)\\n .div(BASE_VIRTUAL_PRICE_PRECISION);\\n // when adding to the base pool,you pay approx 50% of the swap fee\\n v.x = v\\n .x\\n .sub(\\n v.x.mul(_getBaseSwapFee(metaSwapStorage.baseSwap)).div(\\n FEE_DENOMINATOR.mul(2)\\n )\\n )\\n .add(xp[v.baseLPTokenIndex]);\\n } else {\\n // both from and to are from the base pool\\n return\\n v.baseSwap.calculateSwap(\\n tokenIndexFrom,\\n tokenIndexTo - v.baseLPTokenIndex,\\n dx\\n );\\n }\\n tokenIndexFrom = v.baseLPTokenIndex;\\n }\\n\\n v.metaIndexTo = v.baseLPTokenIndex;\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n v.metaIndexTo = tokenIndexTo;\\n }\\n\\n {\\n uint256 y = SwapUtils.getY(\\n self._getAPrecise(),\\n tokenIndexFrom,\\n v.metaIndexTo,\\n v.x,\\n xp\\n );\\n v.dy = xp[v.metaIndexTo].sub(y).sub(1);\\n uint256 dyFee = v.dy.mul(self.swapFee).div(FEE_DENOMINATOR);\\n v.dy = v.dy.sub(dyFee);\\n }\\n\\n if (tokenIndexTo < v.baseLPTokenIndex) {\\n // tokenTo is from this pool\\n v.dy = v.dy.div(self.tokenPrecisionMultipliers[v.metaIndexTo]);\\n } else {\\n // tokenTo is from the base pool\\n v.dy = v.baseSwap.calculateRemoveLiquidityOneToken(\\n v.dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(v.baseVirtualPrice),\\n tokenIndexTo - v.baseLPTokenIndex\\n );\\n }\\n\\n return v.dy;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param metaSwapStorage MetaSwap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = self._getAPrecise();\\n uint256 d0;\\n uint256 d1;\\n {\\n uint256 baseVirtualPrice = _getBaseVirtualPrice(metaSwapStorage);\\n uint256[] memory balances1 = self.balances;\\n uint256[] memory tokenPrecisionMultipliers = self\\n .tokenPrecisionMultipliers;\\n uint256 numTokens = balances1.length;\\n d0 = SwapUtils.getD(\\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\\n a\\n );\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (deposit) {\\n balances1[i] = balances1[i].add(amounts[i]);\\n } else {\\n balances1[i] = balances1[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n }\\n d1 = SwapUtils.getD(\\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\\n a\\n );\\n }\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return d1.sub(d0).mul(totalSupply).div(d0);\\n } else {\\n return d0.sub(d1).mul(totalSupply).div(d0);\\n }\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n uint256 pooledTokensLength = self.pooledTokens.length;\\n require(\\n tokenIndexFrom < pooledTokensLength &&\\n tokenIndexTo < pooledTokensLength,\\n \\\"Token index is out of range\\\"\\n );\\n }\\n\\n uint256 transferredDx;\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n\\n {\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n transferredDx = tokenFrom.balanceOf(address(this)).sub(\\n beforeBalance\\n );\\n }\\n }\\n\\n (uint256 dy, uint256 dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n transferredDx,\\n _updateBaseVirtualPrice(metaSwapStorage)\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\\n self.tokenPrecisionMultipliers[tokenIndexTo]\\n );\\n\\n self.balances[tokenIndexFrom] = self.balances[tokenIndexFrom].add(\\n transferredDx\\n );\\n self.balances[tokenIndexTo] = self.balances[tokenIndexTo].sub(dy).sub(\\n dyAdminFee\\n );\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(\\n msg.sender,\\n transferredDx,\\n dy,\\n tokenIndexFrom,\\n tokenIndexTo\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Swaps with the underlying tokens of the base Swap pool. For this function,\\n * the token indices are flattened out so that underlying tokens are represented\\n * in the indices.\\n * @dev Since this calls multiple external functions during the execution,\\n * it is recommended to protect any function that depends on this with reentrancy guards.\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swapUnderlying(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n SwapUnderlyingInfo memory v = SwapUnderlyingInfo(\\n 0,\\n 0,\\n 0,\\n self.tokenPrecisionMultipliers,\\n self.balances,\\n metaSwapStorage.baseTokens,\\n IERC20(address(0)),\\n 0,\\n IERC20(address(0)),\\n 0,\\n _updateBaseVirtualPrice(metaSwapStorage)\\n );\\n\\n uint8 baseLPTokenIndex = uint8(v.oldBalances.length.sub(1));\\n\\n {\\n uint8 maxRange = uint8(baseLPTokenIndex + v.baseTokens.length);\\n require(\\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\\n \\\"Token index out of range\\\"\\n );\\n }\\n\\n ISwap baseSwap = metaSwapStorage.baseSwap;\\n\\n // Find the address of the token swapping from and the index in MetaSwap's token list\\n if (tokenIndexFrom < baseLPTokenIndex) {\\n v.tokenFrom = self.pooledTokens[tokenIndexFrom];\\n v.metaIndexFrom = tokenIndexFrom;\\n } else {\\n v.tokenFrom = v.baseTokens[tokenIndexFrom - baseLPTokenIndex];\\n v.metaIndexFrom = baseLPTokenIndex;\\n }\\n\\n // Find the address of the token swapping to and the index in MetaSwap's token list\\n if (tokenIndexTo < baseLPTokenIndex) {\\n v.tokenTo = self.pooledTokens[tokenIndexTo];\\n v.metaIndexTo = tokenIndexTo;\\n } else {\\n v.tokenTo = v.baseTokens[tokenIndexTo - baseLPTokenIndex];\\n v.metaIndexTo = baseLPTokenIndex;\\n }\\n\\n // Check for possible fee on transfer\\n v.dx = v.tokenFrom.balanceOf(address(this));\\n v.tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n v.dx = v.tokenFrom.balanceOf(address(this)).sub(v.dx); // update dx in case of fee on transfer\\n\\n if (\\n tokenIndexFrom < baseLPTokenIndex || tokenIndexTo < baseLPTokenIndex\\n ) {\\n // Either one of the tokens belongs to the MetaSwap tokens list\\n uint256[] memory xp = _xp(\\n v.oldBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n );\\n\\n if (tokenIndexFrom < baseLPTokenIndex) {\\n // Swapping from a MetaSwap token\\n v.x = xp[tokenIndexFrom].add(\\n dx.mul(v.tokenPrecisionMultipliers[tokenIndexFrom])\\n );\\n } else {\\n // Swapping from one of the tokens hosted in the base Swap\\n // This case requires adding the underlying token to the base Swap, then\\n // using the base LP token to swap to the desired token\\n uint256[] memory baseAmounts = new uint256[](\\n v.baseTokens.length\\n );\\n baseAmounts[tokenIndexFrom - baseLPTokenIndex] = v.dx;\\n\\n // Add liquidity to the base Swap contract and receive base LP token\\n v.dx = baseSwap.addLiquidity(baseAmounts, 0, block.timestamp);\\n\\n // Calculate the value of total amount of baseLPToken we end up with\\n v.x = v\\n .dx\\n .mul(v.baseVirtualPrice)\\n .div(BASE_VIRTUAL_PRICE_PRECISION)\\n .add(xp[baseLPTokenIndex]);\\n }\\n\\n // Calculate how much to withdraw in MetaSwap level and the the associated swap fee\\n uint256 dyFee;\\n {\\n uint256 y = SwapUtils.getY(\\n self._getAPrecise(),\\n v.metaIndexFrom,\\n v.metaIndexTo,\\n v.x,\\n xp\\n );\\n v.dy = xp[v.metaIndexTo].sub(y).sub(1);\\n if (tokenIndexTo >= baseLPTokenIndex) {\\n // When swapping to a base Swap token, scale down dy by its virtual price\\n v.dy = v.dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(\\n v.baseVirtualPrice\\n );\\n }\\n dyFee = v.dy.mul(self.swapFee).div(FEE_DENOMINATOR);\\n v.dy = v.dy.sub(dyFee).div(\\n v.tokenPrecisionMultipliers[v.metaIndexTo]\\n );\\n }\\n\\n // Update the balances array according to the calculated input and output amount\\n {\\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(\\n FEE_DENOMINATOR\\n );\\n dyAdminFee = dyAdminFee.div(\\n v.tokenPrecisionMultipliers[v.metaIndexTo]\\n );\\n self.balances[v.metaIndexFrom] = v\\n .oldBalances[v.metaIndexFrom]\\n .add(v.dx);\\n self.balances[v.metaIndexTo] = v\\n .oldBalances[v.metaIndexTo]\\n .sub(v.dy)\\n .sub(dyAdminFee);\\n }\\n\\n if (tokenIndexTo >= baseLPTokenIndex) {\\n // When swapping to a token that belongs to the base Swap, burn the LP token\\n // and withdraw the desired token from the base pool\\n uint256 oldBalance = v.tokenTo.balanceOf(address(this));\\n baseSwap.removeLiquidityOneToken(\\n v.dy,\\n tokenIndexTo - baseLPTokenIndex,\\n 0,\\n block.timestamp\\n );\\n v.dy = v.tokenTo.balanceOf(address(this)) - oldBalance;\\n }\\n\\n // Check the amount of token to send meets minDy\\n require(v.dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n } else {\\n // Both tokens are from the base Swap pool\\n // Do a swap through the base Swap\\n v.dy = v.tokenTo.balanceOf(address(this));\\n baseSwap.swap(\\n tokenIndexFrom - baseLPTokenIndex,\\n tokenIndexTo - baseLPTokenIndex,\\n v.dx,\\n minDy,\\n block.timestamp\\n );\\n v.dy = v.tokenTo.balanceOf(address(this)).sub(v.dy);\\n }\\n\\n // Send the desired token to the caller\\n v.tokenTo.safeTransfer(msg.sender, v.dy);\\n\\n emit TokenSwapUnderlying(\\n msg.sender,\\n dx,\\n v.dy,\\n tokenIndexFrom,\\n tokenIndexTo\\n );\\n\\n return v.dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n self.lpToken,\\n 0,\\n self._getAPrecise(),\\n _updateBaseVirtualPrice(metaSwapStorage),\\n self.tokenPrecisionMultipliers,\\n self.balances\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = SwapUtils.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n }\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\\n beforeBalance\\n );\\n }\\n\\n v.newBalances[i] = v.newBalances[i].add(amounts[i]);\\n }\\n\\n // invariant after change\\n v.d1 = SwapUtils.getD(\\n _xp(v.newBalances, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256 toMint;\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = SwapUtils._feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = v.d1.mul(self.balances[i]).div(v.d0);\\n fees[i] = feePerToken\\n .mul(idealBalance.difference(v.newBalances[i]))\\n .div(FEE_DENOMINATOR);\\n self.balances[i] = v.newBalances[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n v.newBalances[i] = v.newBalances[i].sub(fees[i]);\\n }\\n v.d2 = SwapUtils.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = v.newBalances;\\n toMint = v.d1;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n self.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.add(toMint)\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPToken lpToken = self.lpToken;\\n uint256 totalSupply = lpToken.totalSupply();\\n uint256 numTokens = self.pooledTokens.length;\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 dyFee;\\n uint256 dy;\\n\\n (dy, dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n _updateBaseVirtualPrice(metaSwapStorage),\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n // Update balances array\\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\\n );\\n\\n // Burn the associated LP token from the caller and send the desired token\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n self.pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n SwapUtils.Swap storage self,\\n MetaSwap storage metaSwapStorage,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n // Using this struct to avoid stack too deep error\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n self.lpToken,\\n 0,\\n self._getAPrecise(),\\n _updateBaseVirtualPrice(metaSwapStorage),\\n self.tokenPrecisionMultipliers,\\n self.balances\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n require(\\n amounts.length == v.newBalances.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n require(maxBurnAmount != 0, \\\"Must burn more than 0\\\");\\n\\n uint256 feePerToken = SwapUtils._feePerToken(\\n self.swapFee,\\n v.newBalances.length\\n );\\n\\n // Calculate how much LPToken should be burned\\n uint256[] memory fees = new uint256[](v.newBalances.length);\\n {\\n uint256[] memory balances1 = new uint256[](v.newBalances.length);\\n\\n v.d0 = SwapUtils.getD(\\n _xp(\\n v.newBalances,\\n v.tokenPrecisionMultipliers,\\n v.baseVirtualPrice\\n ),\\n v.preciseA\\n );\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n balances1[i] = v.newBalances[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n v.d1 = SwapUtils.getD(\\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n uint256 idealBalance = v.d1.mul(v.newBalances[i]).div(v.d0);\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\\n self.balances[i] = balances1[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n balances1[i] = balances1[i].sub(fees[i]);\\n }\\n\\n v.d2 = SwapUtils.getD(\\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\\n v.preciseA\\n );\\n }\\n\\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n\\n // Scale up by withdraw fee\\n tokenAmount = tokenAmount.add(1);\\n\\n // Check for max burn amount\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n // Burn the calculated amount of LPToken from the caller and send the desired tokens\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n for (uint256 i = 0; i < v.newBalances.length; i++) {\\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.sub(tokenAmount)\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice Determines if the stored value of base Swap's virtual price is expired.\\n * If the last update was past the BASE_CACHE_EXPIRE_TIME, then update the stored value.\\n *\\n * @param metaSwapStorage MetaSwap struct to read from and write to\\n * @return base Swap's virtual price\\n */\\n function _updateBaseVirtualPrice(MetaSwap storage metaSwapStorage)\\n internal\\n returns (uint256)\\n {\\n if (\\n block.timestamp >\\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\\n ) {\\n // When the cache is expired, update it\\n uint256 baseVirtualPrice = ISwap(metaSwapStorage.baseSwap)\\n .getVirtualPrice();\\n metaSwapStorage.baseVirtualPrice = baseVirtualPrice;\\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\\n return baseVirtualPrice;\\n } else {\\n return metaSwapStorage.baseVirtualPrice;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xb64b855d7c6af37c3ccd1713e9079e61baf14b4c8f984b7ef77ba33ceab87e7d\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessMetaSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"./PermissionlessSwap.sol\\\";\\nimport \\\"./ShareProtocolFee.sol\\\";\\nimport \\\"../meta/MetaSwapUtils.sol\\\";\\nimport \\\"../meta/MetaSwap.sol\\\";\\n\\n/**\\n * @title MetaSwap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\\n *\\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\\n * deployment size.\\n */\\ncontract PermissionlessMetaSwap is MetaSwap, ShareProtocolFee {\\n using PermissionlessSwapUtils for SwapUtils.Swap;\\n\\n /**\\n * @notice Constructor for the PermissionlessSwap contract.\\n * @param _masterRegistry address of the MasterRegistry contract\\n */\\n constructor(IMasterRegistry _masterRegistry)\\n public\\n ShareProtocolFee(_masterRegistry)\\n {}\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n function initializeMetaSwap(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress,\\n ISwap baseSwap\\n ) public payable virtual override initializer {\\n MetaSwap.initializeMetaSwap(\\n _pooledTokens,\\n decimals,\\n lpTokenName,\\n lpTokenSymbol,\\n _a,\\n _fee,\\n _adminFee,\\n lpTokenTargetAddress,\\n baseSwap\\n );\\n _updateFeeCollectorCache(MASTER_REGISTRY);\\n }\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner and the fee collector\\n */\\n function withdrawAdminFees()\\n external\\n payable\\n virtual\\n override(ShareProtocolFee, Swap)\\n {\\n require(\\n msg.sender == owner() || msg.sender == feeCollector,\\n \\\"Caller is not authorized\\\"\\n );\\n PermissionlessSwapUtils.withdrawAdminFees(\\n swapStorage,\\n owner(),\\n feeCollector\\n );\\n }\\n}\\n\",\"keccak256\":\"0x9157d2035911577e56740f874bf237dfcd5245de8e80faca443adf7fd1fd1937\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"../Swap.sol\\\";\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\nimport \\\"./PermissionlessSwapUtils.sol\\\";\\nimport \\\"./ShareProtocolFee.sol\\\";\\n\\n/**\\n * @title Swap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs. Part of this fee is given to the creator of the pool as an Admin fee,\\n * the amount of which is set when the pool is created. Saddle will collect to 50% of these Admin fees.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * @dev Most of the logic is stored as a library `PermissionlessSwapUtils` for the sake of reducing\\n * contract's deployment size.\\n */\\ncontract PermissionlessSwap is Swap, ShareProtocolFee {\\n using PermissionlessSwapUtils for SwapUtils.Swap;\\n\\n /**\\n * @notice Constructor for the PermissionlessSwap contract.\\n * @param _masterRegistry address of the MasterRegistry contract\\n */\\n constructor(IMasterRegistry _masterRegistry)\\n public\\n ShareProtocolFee(_masterRegistry)\\n {}\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n /**\\n * @notice Updates cached address of the fee collector\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual override initializer {\\n Swap.initialize(\\n _pooledTokens,\\n decimals,\\n lpTokenName,\\n lpTokenSymbol,\\n _a,\\n _fee,\\n _adminFee,\\n lpTokenTargetAddress\\n );\\n _updateFeeCollectorCache(MASTER_REGISTRY);\\n }\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner and the fee collector.\\n */\\n function withdrawAdminFees()\\n external\\n payable\\n virtual\\n override(Swap, ShareProtocolFee)\\n {\\n require(\\n msg.sender == owner() || msg.sender == feeCollector,\\n \\\"Caller is not authorized\\\"\\n );\\n PermissionlessSwapUtils.withdrawAdminFees(\\n swapStorage,\\n owner(),\\n feeCollector\\n );\\n }\\n}\\n\",\"keccak256\":\"0x36bb4e9bb6cfea001cb6d44018f5297c0552dddd1958e06232b529e4fe6deb58\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessSwapUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"../SwapUtils.sol\\\";\\n\\n/**\\n * @title PermissionlessSwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary PermissionlessSwapUtils {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n /**\\n * @notice Withdraw all admin fees to two addresses evenly\\n * @param self Swap struct to withdraw fees from\\n * @param creator Address to send hald of the fees to. For the creator of the community pool.\\n * @param protocol Address to send the half of the fees to. For the protocol fee collection.\\n */\\n function withdrawAdminFees(\\n SwapUtils.Swap storage self,\\n address creator,\\n address protocol\\n ) internal {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)).sub(\\n self.balances[i]\\n ) / 2;\\n if (balance != 0) {\\n token.safeTransfer(creator, balance);\\n token.safeTransfer(protocol, balance);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1b94e14de31e95f82bf8f47aa65f4c68c7152823cac6daf2b50c3923f20f2ecc\",\"license\":\"MIT\"},\"contracts/permissionless/ShareProtocolFee.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\n\\nabstract contract ShareProtocolFee {\\n IMasterRegistry public immutable MASTER_REGISTRY;\\n bytes32 public constant FEE_COLLECTOR_NAME =\\n 0x466565436f6c6c6563746f720000000000000000000000000000000000000000;\\n address public feeCollector;\\n\\n constructor(IMasterRegistry _masterRegistry) public {\\n MASTER_REGISTRY = _masterRegistry;\\n _updateFeeCollectorCache(_masterRegistry);\\n }\\n\\n /**\\n * @notice Updates cached address of the fee collector\\n */\\n function updateFeeCollectorCache() public payable virtual {\\n _updateFeeCollectorCache(MASTER_REGISTRY);\\n }\\n\\n function _updateFeeCollectorCache(IMasterRegistry masterRegistry)\\n internal\\n virtual\\n {\\n address _feeCollector = masterRegistry.resolveNameToLatestAddress(\\n FEE_COLLECTOR_NAME\\n );\\n require(_feeCollector != address(0), \\\"Fee collector cannot be empty\\\");\\n feeCollector = _feeCollector;\\n }\\n\\n /**\\n * @notice Withdraws admin fees to appropriate addresses\\n */\\n function withdrawAdminFees() external payable virtual;\\n}\\n\",\"keccak256\":\"0x4af76c8dd2356c160c60f1378a11a832f0e99e9bbb36908b95d3743f3aecbc32\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b50604051620048a2380380620048a2833981810160405260208110156200003757600080fd5b50516001600160601b0319606082901b166080528062000057816200005f565b505062000167565b6000816001600160a01b0316633705f6256b2332b2a1b7b63632b1ba37b960a11b60001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015620000b857600080fd5b505afa158015620000cd573d6000803e3d6000fd5b505050506040513d6020811015620000e457600080fd5b505190506001600160a01b03811662000144576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d880546001600160a01b0319166001600160a01b039290921691909117905550565b60805160601c6147136200018f60003980610fd4528061101b52806123ed52506147136000f3fe60806040526004361061026a5760003560e01c806382b8660011610153578063ac841ed9116100cb578063e25aa5fa1161007f578063ef0a712f11610064578063ef0a712f14610d83578063f2fad2b614610dad578063f2fde38b14610dd75761026a565b8063e25aa5fa14610cef578063e6ab280614610d045761026a565b8063c415b95c116100b0578063c415b95c14610cbd578063c4db7fa014610cd2578063d46300fd14610cda5761026a565b8063ac841ed914610a58578063b28cb6dc14610a6d5761026a565b80638da5cb5b1161012257806391ceb3eb1161010757806391ceb3eb146109d9578063a434439014610a06578063a95b089f14610a1b5761026a565b80638da5cb5b14610988578063916955861461099d5761026a565b806382b86600146108975780638456cb59146108e057806384cdd9bc146108f55780638beb60b61461096b5761026a565b80633f4ba83a116101e65780635fd65f0f116101b5578063715018a61161019a578063715018a6146107fc57806375d8e3e41461081157806378e0fae81461084e5761026a565b80635fd65f0f1461075d57806366c0bd24146107b35761026a565b80633f4ba83a146106865780634d49e87d1461069b578063593d132c146107115780635c975abb146107345761026a565b80632d74d4e91161023d578063342a87a111610222578063342a87a11461060457806334e19907146106375780633e3a1560146106545761026a565b80632d74d4e91461050057806331cd52b01461053d5761026a565b80630419b45a1461026f5780630ba8195914610279578063118e1c77146102a05780632472374d146104f8575b600080fd5b610277610e0a565b005b34801561028557600080fd5b5061028e610eac565b60408051918252519081900360200190f35b61027760048036036101208110156102b757600080fd5b8101906020810181356401000000008111156102d257600080fd5b8201836020820111156102e457600080fd5b8035906020019184602083028401116401000000008311171561030657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561035657600080fd5b82018360208201111561036857600080fd5b8035906020019184602083028401116401000000008311171561038a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156103da57600080fd5b8201836020820111156103ec57600080fd5b8035906020019184600183028401116401000000008311171561040e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561046157600080fd5b82018360208201111561047357600080fd5b8035906020019184600183028401116401000000008311171561049557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050506020810135906040810135906001600160a01b0360608201358116916080013516610f31565b610277611016565b34801561050c57600080fd5b5061051561103f565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b6105b46004803603606081101561055357600080fd5b8135919081019060408101602082013564010000000081111561057557600080fd5b82018360208201111561058757600080fd5b803590602001918460208302840111640100000000831117156105a957600080fd5b919350915035611057565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156105f05781810151838201526020016105d8565b505050509050019250505060405180910390f35b34801561061057600080fd5b5061028e6004803603604081101561062757600080fd5b508035906020013560ff16611294565b6102776004803603602081101561064d57600080fd5b503561134f565b61028e6004803603608081101561066a57600080fd5b5080359060ff6020820135169060408101359060600135611450565b34801561069257600080fd5b50610277611623565b61028e600480360360608110156106b157600080fd5b8101906020810181356401000000008111156106cc57600080fd5b8201836020820111156106de57600080fd5b8035906020019184602083028401116401000000008311171561070057600080fd5b91935091508035906020013561169f565b6102776004803603604081101561072757600080fd5b5080359060200135611846565b34801561074057600080fd5b5061074961194f565b604080519115158252519081900360200190f35b34801561076957600080fd5b50610772611958565b604080519788526020880196909652868601949094526060860192909252608085015260a08401526001600160a01b031660c0830152519081900360e00190f35b3480156107bf57600080fd5b506107e6600480360360208110156107d657600080fd5b50356001600160a01b0316611979565b6040805160ff9092168252519081900360200190f35b34801561080857600080fd5b50610277611a06565b34801561081d57600080fd5b5061028e6004803603606081101561083457600080fd5b5060ff813581169160208101359091169060400135611adc565b34801561085a57600080fd5b5061028e600480360360a081101561087157600080fd5b5060ff813581169160208101359091169060408101359060608101359060800135611ba0565b3480156108a357600080fd5b506108c4600480360360208110156108ba57600080fd5b503560ff16611d7a565b604080516001600160a01b039092168252519081900360200190f35b3480156108ec57600080fd5b50610277611e02565b61028e6004803603606081101561090b57600080fd5b81019060208101813564010000000081111561092657600080fd5b82018360208201111561093857600080fd5b8035906020019184602083028401116401000000008311171561095a57600080fd5b919350915080359060200135611e7e565b6102776004803603602081101561098157600080fd5b5035612025565b34801561099457600080fd5b506108c461210b565b61028e600480360360a08110156109b357600080fd5b5060ff81358116916020810135909116906040810135906060810135906080013561211a565b3480156109e557600080fd5b5061028e600480360360208110156109fc57600080fd5b503560ff166122ba565b348015610a1257600080fd5b5061028e612339565b348015610a2757600080fd5b5061028e60048036036060811015610a3e57600080fd5b5060ff81358116916020810135909116906040013561235d565b348015610a6457600080fd5b506108c46123eb565b6102776004803603610100811015610a8457600080fd5b810190602081018135640100000000811115610a9f57600080fd5b820183602082011115610ab157600080fd5b80359060200191846020830284011164010000000083111715610ad357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610b2357600080fd5b820183602082011115610b3557600080fd5b80359060200191846020830284011164010000000083111715610b5757600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610ba757600080fd5b820183602082011115610bb957600080fd5b80359060200191846001830284011164010000000083111715610bdb57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050640100000000811115610c2e57600080fd5b820183602082011115610c4057600080fd5b80359060200191846001830284011164010000000083111715610c6257600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050823593505050602081013590604081013590606001356001600160a01b031661240f565b348015610cc957600080fd5b506108c46124f4565b610277612503565b348015610ce657600080fd5b5061028e6125fc565b348015610cfb57600080fd5b5061028e612650565b348015610d1057600080fd5b5061028e60048036036040811015610d2757600080fd5b810190602081018135640100000000811115610d4257600080fd5b820183602082011115610d5457600080fd5b80359060200191846020830284011164010000000083111715610d7657600080fd5b91935091503515156126ab565b348015610d8f57600080fd5b5061028e60048036036020811015610da657600080fd5b5035612747565b348015610db957600080fd5b506105b460048036036020811015610dd057600080fd5b50356127d5565b348015610de357600080fd5b5061027760048036036020811015610dfa57600080fd5b50356001600160a01b031661291f565b610e1261210b565b6001600160a01b0316336001600160a01b03161480610e3b575060d8546001600160a01b031633145b610e8c576040805162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f7420617574686f72697a65640000000000000000604482015290519081900360640190fd5b610eaa60c9610e9961210b565b60d8546001600160a01b0316612a4c565b565b600060c973FdA5D2ad8b6d3884AbB799DA66f57175E870694163c9b64dcb90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610f0057600080fd5b505af4158015610f14573d6000803e3d6000fd5b505050506040513d6020811015610f2a57600080fd5b5051905090565b600054610100900460ff1680610f4a5750610f4a612bb3565b80610f58575060005460ff16155b610f935760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015610fbe576000805460ff1961ff0019909116610100171660011790555b610fcf8a8a8a8a8a8a8a8a8a612bc4565b610ff87f0000000000000000000000000000000000000000000000000000000000000000612f9c565b801561100a576000805461ff00191690555b50505050505050505050565b610eaa7f0000000000000000000000000000000000000000000000000000000000000000612f9c565b60d45460d55460d6546001600160a01b039092169183565b6060600260975414156110b1576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755814281101561110c576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c9734a5208f83a17e030a18830521e4064e80728c4fc6373fd6b3e90918888886040518563ffffffff1660e01b815260040180858152602001848152602001806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060006040518083038186803b15801561119d57600080fd5b505af41580156111b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405260208110156111f857600080fd5b810190808051604051939291908464010000000082111561121857600080fd5b90830190602082018581111561122d57600080fd5b825186602082028301116401000000008211171561124a57600080fd5b82525081516020918201928201910280838360005b8381101561127757818101518382015260200161125f565b505050509050016040525050509150506001609755949350505050565b604080517ff6ada8c200000000000000000000000000000000000000000000000000000000815260c9600482015260d460248201526044810184905260ff83166064820152905160009173feEa4D1BacB0519E8f952460A70719944fe56Ee09163f6ada8c291608480820192602092909190829003018186803b15801561131a57600080fd5b505af415801561132e573d6000803e3d6000fd5b505050506040513d602081101561134457600080fd5b505190505b92915050565b6113576130c9565b6001600160a01b031661136861210b565b6001600160a01b0316146113c3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f467e186c00000000000000000000000000000000000000000000000000000000815260c96004820152602481018390529051734a5208f83a17e030a18830521e4064e80728c4fc9163467e186c916044808301926000929190829003018186803b15801561143557600080fd5b505af4158015611449573d6000803e3d6000fd5b5050505050565b6000600260975414156114aa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556114b761194f565b15611509576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b818042111561155f576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fc1a6627300000000000000000000000000000000000000000000000000000000815260c9600482015260d460248201526044810188905260ff8716606482015260848101869052905173feEa4D1BacB0519E8f952460A70719944fe56Ee09163c1a662739160a4808301926020929190829003018186803b1580156115e857600080fd5b505af41580156115fc573d6000803e3d6000fd5b505050506040513d602081101561161257600080fd5b505160016097559695505050505050565b61162b6130c9565b6001600160a01b031661163c61210b565b6001600160a01b031614611697576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610eaa6130cd565b6000600260975414156116f9576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561170661194f565b15611758576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b81804211156117ae576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b73feEa4D1BacB0519E8f952460A70719944fe56Ee063d1ab4b4a60c960d48989896040518663ffffffff1660e01b815260040180868152602001858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b1580156115e857600080fd5b61184e6130c9565b6001600160a01b031661185f61210b565b6001600160a01b0316146118ba576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f58fdd79b00000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260448101839052905173FdA5D2ad8b6d3884AbB799DA66f57175E8706941916358fdd79b916064808301926000929190829003018186803b15801561193357600080fd5b505af4158015611947573d6000803e3d6000fd5b505050505050565b60655460ff1690565b60c95460ca5460cb5460cc5460cd5460ce5460cf546001600160a01b031687565b6001600160a01b038116600081815260d36020526040812054909160ff909116906119a382611d7a565b6001600160a01b0316146119fe576040805162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f74206578697374000000000000000000000000604482015290519081900360640190fd5b90505b919050565b611a0e6130c9565b6001600160a01b0316611a1f61210b565b6001600160a01b031614611a7a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080517fd45757ba00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff80861660448301528416606482015260848101839052905160009173feEa4D1BacB0519E8f952460A70719944fe56Ee09163d45757ba9160a480820192602092909190829003018186803b158015611b6a57600080fd5b505af4158015611b7e573d6000803e3d6000fd5b505050506040513d6020811015611b9457600080fd5b505190505b9392505050565b600060026097541415611bfa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611c0761194f565b15611c59576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611caf576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517e80247a00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff808a166044830152881660648201526084810187905260a48101869052905173feEa4D1BacB0519E8f952460A70719944fe56Ee0916280247a9160c4808301926020929190829003018186803b158015611d3e57600080fd5b505af4158015611d52573d6000803e3d6000fd5b505050506040513d6020811015611d6857600080fd5b50516001609755979650505050505050565b60d05460009060ff831610611dd6576040805162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e67650000000000000000000000000000000000000000604482015290519081900360640190fd5b60d0805460ff8416908110611de757fe5b6000918252602090912001546001600160a01b031692915050565b611e0a6130c9565b6001600160a01b0316611e1b61210b565b6001600160a01b031614611e76576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610eaa613176565b600060026097541415611ed8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611ee561194f565b15611f37576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611f8d576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b73feEa4D1BacB0519E8f952460A70719944fe56Ee0637e97165660c960d48989896040518663ffffffff1660e01b815260040180868152602001858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b1580156115e857600080fd5b61202d6130c9565b6001600160a01b031661203e61210b565b6001600160a01b031614612099576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f7046727600000000000000000000000000000000000000000000000000000000815260c96004820152602481018390529051734a5208f83a17e030a18830521e4064e80728c4fc916370467276916044808301926000929190829003018186803b15801561143557600080fd5b6033546001600160a01b031690565b600060026097541415612174576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561218161194f565b156121d3576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115612229576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517f98414eed00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff808a166044830152881660648201526084810187905260a48101869052905173feEa4D1BacB0519E8f952460A70719944fe56Ee0916398414eed9160c4808301926020929190829003018186803b158015611d3e57600080fd5b60d05460009060ff831610612316576040805162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e67650000000000000000000000000000604482015290519081900360640190fd5b60d2805460ff841690811061232757fe5b90600052602060002001549050919050565b7f466565436f6c6c6563746f72000000000000000000000000000000000000000081565b604080517f5afb90ff00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff80861660448301528416606482015260848101839052905160009173feEa4D1BacB0519E8f952460A70719944fe56Ee091635afb90ff9160a480820192602092909190829003018186803b158015611b6a57600080fd5b7f000000000000000000000000000000000000000000000000000000000000000081565b600054610100900460ff16806124285750612428612bb3565b80612436575060005460ff16155b6124715760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff1615801561249c576000805460ff1961ff0019909116610100171660011790555b6040805162461bcd60e51b815260206004820181905260248201527f75736520696e697469616c697a654d65746153776170282920696e7374656164604482015290519081900360640190fd5b505050505050505050565b60d8546001600160a01b031681565b61250b6130c9565b6001600160a01b031661251c61210b565b6001600160a01b031614612577576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517ff14e211e00000000000000000000000000000000000000000000000000000000815260c96004820152905173FdA5D2ad8b6d3884AbB799DA66f57175E87069419163f14e211e916024808301926000929190829003018186803b1580156125e257600080fd5b505af41580156125f6573d6000803e3d6000fd5b50505050565b600060c973FdA5D2ad8b6d3884AbB799DA66f57175E870694163b0a14cfc90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610f0057600080fd5b600073feEa4D1BacB0519E8f952460A70719944fe56Ee063e9d4d07760c960d46040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015610f0057600080fd5b600073feEa4D1BacB0519E8f952460A70719944fe56Ee06378b0bcbe60c960d48787876040518663ffffffff1660e01b8152600401808681526020018581526020018060200183151581526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b158015611b6a57600080fd5b600060c9734a5208f83a17e030a18830521e4064e80728c4fc637d0481609091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156127a357600080fd5b505af41580156127b7573d6000803e3d6000fd5b505050506040513d60208110156127cd57600080fd5b505192915050565b606060c9734a5208f83a17e030a18830521e4064e80728c4fc6370703e4a9091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561283157600080fd5b505af4158015612845573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052602081101561288c57600080fd5b81019080805160405193929190846401000000008211156128ac57600080fd5b9083019060208201858111156128c157600080fd5b82518660208202830111640100000000821117156128de57600080fd5b82525081516020918201928201910280838360005b8381101561290b5781810151838201526020016128f3565b505050509050016040525050509050919050565b6129276130c9565b6001600160a01b031661293861210b565b6001600160a01b031614612993576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166129d85760405162461bcd60e51b815260040180806020018281038252602681526020018061459b6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b606083600701805480602002602001604051908101604052809291908181526020018280548015612aa657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a88575b5050505050905060005b8151811015611449576000828281518110612ac757fe5b6020026020010151905060006002612b71886009018581548110612ae757fe5b9060005260206000200154846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612b3f57600080fd5b505afa158015612b53573d6000803e3d6000fd5b505050506040513d6020811015612b6957600080fd5b505190613206565b81612b7857fe5b0490508015612ba957612b956001600160a01b0383168783613263565b612ba96001600160a01b0383168683613263565b5050600101612ab0565b6000612bbe306132e8565b15905090565b600054610100900460ff1680612bdd5750612bdd612bb3565b80612beb575060005460ff16155b612c265760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015612c51576000805460ff1961ff0019909116610100171660011790555b612c618a8a8a8a8a8a8a8a6132ee565b60d480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038416908117909155604080517fe25aa5fa000000000000000000000000000000000000000000000000000000008152905163e25aa5fa91600480820192602092909190829003018186803b158015612ce657600080fd5b505afa158015612cfa573d6000803e3d6000fd5b505050506040513d6020811015612d1057600080fd5b505160d5554260d65560005b60208160ff161015612e3757826001600160a01b03166382b86600826040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b158015612d6f57600080fd5b505afa925050508015612d9457506040513d6020811015612d8f57600080fd5b505160015b612d9d57612e37565b60d780546001810182556000919091527f8a012a6de2943a5aa4d77acf5e695d4456760a3f1f30a5d6dc2079599187a0710180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155612e2e90857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff613ae9565b50600101612d1c565b60018160ff1611612e795760405162461bcd60e51b815260040180806020018281038252602481526020018061465a6024913960400191505060405180910390fd5b5060008a60018c510381518110612e8c57fe5b60200260200101519050826001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ed957600080fd5b505afa158015612eed573d6000803e3d6000fd5b505050506040513d6020811015612f0357600080fd5b50516001600160a01b031614612f4a5760405162461bcd60e51b81526004018080602001828103825260248152602001806146156024913960400191505060405180910390fd5b612f7e6001600160a01b038216847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff613ae9565b50801561100a576000805461ff001916905550505050505050505050565b6000816001600160a01b0316633705f6257f466565436f6c6c6563746f72000000000000000000000000000000000000000060001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561300557600080fd5b505afa158015613019573d6000803e3d6000fd5b505050506040513d602081101561302f57600080fd5b505190506001600160a01b03811661308e576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b3390565b6130d561194f565b613126576040805162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6131596130c9565b604080516001600160a01b039092168252519081900360200190a1565b61317e61194f565b156131d0576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131596130c9565b60008282111561325d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526132e3908490613c3f565b505050565b3b151590565b600054610100900460ff16806133075750613307612bb3565b80613315575060005460ff16155b6133505760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff1615801561337b576000805460ff1961ff0019909116610100171660011790555b613383613cf0565b61338b613daa565b60018951116133e1576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d203100000000000000604482015290519081900360640190fd5b602089511115613438576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e20333200000000000000604482015290519081900360640190fd5b875189511461348e576040805162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d6174636800604482015290519081900360640190fd5b6060885167ffffffffffffffff811180156134a857600080fd5b506040519080825280602002602001820160405280156134d2578160200160208202803683370190505b50905060005b8a518160ff1610156137505760ff8116156135c15760d360008c8360ff168151811061350057fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615801561357057508a8160ff168151811061353e57fe5b60200260200101516001600160a01b03168b60008151811061355c57fe5b60200260200101516001600160a01b031614155b6135c1576040805162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e7300000000000000000000000000000000604482015290519081900360640190fd5b60006001600160a01b03168b8260ff16815181106135db57fe5b60200260200101516001600160a01b0316141561363f576040805162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d3230000000604482015290519081900360640190fd5b601260ff168a8260ff168151811061365357fe5b602002602001015160ff1611156136b1576040805162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d6178000000000000604482015290519081900360640190fd5b6136e18a8260ff16815181106136c357fe5b602002602001015160ff16601260ff1661320690919063ffffffff16565b600a0a828260ff16815181106136f357fe5b6020026020010181815250508060d360008d8460ff168151811061371357fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191660ff929092169190911790556001016134d8565b50620f424086106137a8576040805162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d0000000000000000000000000000604482015290519081900360640190fd5b6305f5e1008510613800576040805162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d000000000000000000000000604482015290519081900360640190fd5b6402540be4008410613859576040805162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d00000000000000604482015290519081900360640190fd5b600061386484613e3f565b9050806001600160a01b0316634cd88b768a8a6040518363ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019080838360005b838110156138c75781810151838201526020016138af565b50505050905090810190601f1680156138f45780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b8381101561392757818101518382015260200161390f565b50505050905090810190601f1680156139545780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561397557600080fd5b505af1158015613989573d6000803e3d6000fd5b505050506040513d602081101561399f57600080fd5b50516139f2576040805162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e6500000000604482015290519081900360640190fd5b60cf80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790558a51613a389060d09060208e019061448a565b508151613a4c9060d1906020850190614507565b508a5167ffffffffffffffff81118015613a6557600080fd5b50604051908082528060200260200182016040528015613a8f578160200160208202803683370190505b508051613aa49160d291602090910190614507565b50613ab0876064613efa565b60c955613abe876064613efa565b60ca55505060cd84905560ce83905580156124e9576000805461ff0019169055505050505050505050565b801580613b885750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015613b5a57600080fd5b505afa158015613b6e573d6000803e3d6000fd5b505050506040513d6020811015613b8457600080fd5b5051155b613bc35760405162461bcd60e51b81526004018080602001828103825260368152602001806146a86036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790526132e39084905b6060613c94826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f539092919063ffffffff16565b8051909150156132e357808060200190516020811015613cb357600080fd5b50516132e35760405162461bcd60e51b815260040180806020018281038252602a81526020018061467e602a913960400191505060405180910390fd5b600054610100900460ff1680613d095750613d09612bb3565b80613d17575060005460ff16155b613d525760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613d7d576000805460ff1961ff0019909116610100171660011790555b613d85613f6a565b613d8d61400a565b613d9561411b565b8015613da7576000805461ff00191690555b50565b600054610100900460ff1680613dc35750613dc3612bb3565b80613dd1575060005460ff16155b613e0c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613e37576000805460ff1961ff0019909116610100171660011790555b613d956141c6565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116611a01576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b600082613f0957506000611349565b82820282848281613f1657fe5b0414611b995760405162461bcd60e51b81526004018080602001828103825260218152602001806146396021913960400191505060405180910390fd5b6060613f62848460008561426c565b949350505050565b600054610100900460ff1680613f835750613f83612bb3565b80613f91575060005460ff16155b613fcc5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613d95576000805460ff1961ff0019909116610100171660011790558015613da7576000805461ff001916905550565b600054610100900460ff16806140235750614023612bb3565b80614031575060005460ff16155b61406c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015614097576000805460ff1961ff0019909116610100171660011790555b60006140a16130c9565b603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015613da7576000805461ff001916905550565b600054610100900460ff16806141345750614134612bb3565b80614142575060005460ff16155b61417d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff161580156141a8576000805460ff1961ff0019909116610100171660011790555b6065805460ff191690558015613da7576000805461ff001916905550565b600054610100900460ff16806141df57506141df612bb3565b806141ed575060005460ff16155b6142285760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015614253576000805460ff1961ff0019909116610100171660011790555b60016097558015613da7576000805461ff001916905550565b6060824710156142ad5760405162461bcd60e51b81526004018080602001828103825260268152602001806145c16026913960400191505060405180910390fd5b6142b6856132e8565b614307576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061436457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614327565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146143c6576040519150601f19603f3d011682016040523d82523d6000602084013e6143cb565b606091505b50915091506143db8282866143e6565b979650505050505050565b606083156143f5575081611b99565b8251156144055782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561444f578181015183820152602001614437565b50505050905090810190601f16801561447c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8280548282559060005260206000209081019282156144f7579160200282015b828111156144f757825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039091161782556020909201916001909101906144aa565b5061450392915061454e565b5090565b828054828255906000526020600020908101928215614542579160200282015b82811115614542578251825591602001919060010190614527565b50614503929150614585565b5b808211156145035780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161454f565b5b80821115614503576000815560010161458656fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564626173654c50546f6b656e206973206e6f74206f776e6564206279206261736553776170536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776261736553776170206d75737420706f6f6c206174206c65617374203220746f6b656e735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220c7695509f9aa5c890124f7995f1eb296fadfc0a22e319887a31f8bbc8a54d78a64736f6c634300060c0033", + "deployedBytecode": "0x60806040526004361061026a5760003560e01c806382b8660011610153578063ac841ed9116100cb578063e25aa5fa1161007f578063ef0a712f11610064578063ef0a712f14610d83578063f2fad2b614610dad578063f2fde38b14610dd75761026a565b8063e25aa5fa14610cef578063e6ab280614610d045761026a565b8063c415b95c116100b0578063c415b95c14610cbd578063c4db7fa014610cd2578063d46300fd14610cda5761026a565b8063ac841ed914610a58578063b28cb6dc14610a6d5761026a565b80638da5cb5b1161012257806391ceb3eb1161010757806391ceb3eb146109d9578063a434439014610a06578063a95b089f14610a1b5761026a565b80638da5cb5b14610988578063916955861461099d5761026a565b806382b86600146108975780638456cb59146108e057806384cdd9bc146108f55780638beb60b61461096b5761026a565b80633f4ba83a116101e65780635fd65f0f116101b5578063715018a61161019a578063715018a6146107fc57806375d8e3e41461081157806378e0fae81461084e5761026a565b80635fd65f0f1461075d57806366c0bd24146107b35761026a565b80633f4ba83a146106865780634d49e87d1461069b578063593d132c146107115780635c975abb146107345761026a565b80632d74d4e91161023d578063342a87a111610222578063342a87a11461060457806334e19907146106375780633e3a1560146106545761026a565b80632d74d4e91461050057806331cd52b01461053d5761026a565b80630419b45a1461026f5780630ba8195914610279578063118e1c77146102a05780632472374d146104f8575b600080fd5b610277610e0a565b005b34801561028557600080fd5b5061028e610eac565b60408051918252519081900360200190f35b61027760048036036101208110156102b757600080fd5b8101906020810181356401000000008111156102d257600080fd5b8201836020820111156102e457600080fd5b8035906020019184602083028401116401000000008311171561030657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561035657600080fd5b82018360208201111561036857600080fd5b8035906020019184602083028401116401000000008311171561038a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156103da57600080fd5b8201836020820111156103ec57600080fd5b8035906020019184600183028401116401000000008311171561040e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561046157600080fd5b82018360208201111561047357600080fd5b8035906020019184600183028401116401000000008311171561049557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050506020810135906040810135906001600160a01b0360608201358116916080013516610f31565b610277611016565b34801561050c57600080fd5b5061051561103f565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b6105b46004803603606081101561055357600080fd5b8135919081019060408101602082013564010000000081111561057557600080fd5b82018360208201111561058757600080fd5b803590602001918460208302840111640100000000831117156105a957600080fd5b919350915035611057565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156105f05781810151838201526020016105d8565b505050509050019250505060405180910390f35b34801561061057600080fd5b5061028e6004803603604081101561062757600080fd5b508035906020013560ff16611294565b6102776004803603602081101561064d57600080fd5b503561134f565b61028e6004803603608081101561066a57600080fd5b5080359060ff6020820135169060408101359060600135611450565b34801561069257600080fd5b50610277611623565b61028e600480360360608110156106b157600080fd5b8101906020810181356401000000008111156106cc57600080fd5b8201836020820111156106de57600080fd5b8035906020019184602083028401116401000000008311171561070057600080fd5b91935091508035906020013561169f565b6102776004803603604081101561072757600080fd5b5080359060200135611846565b34801561074057600080fd5b5061074961194f565b604080519115158252519081900360200190f35b34801561076957600080fd5b50610772611958565b604080519788526020880196909652868601949094526060860192909252608085015260a08401526001600160a01b031660c0830152519081900360e00190f35b3480156107bf57600080fd5b506107e6600480360360208110156107d657600080fd5b50356001600160a01b0316611979565b6040805160ff9092168252519081900360200190f35b34801561080857600080fd5b50610277611a06565b34801561081d57600080fd5b5061028e6004803603606081101561083457600080fd5b5060ff813581169160208101359091169060400135611adc565b34801561085a57600080fd5b5061028e600480360360a081101561087157600080fd5b5060ff813581169160208101359091169060408101359060608101359060800135611ba0565b3480156108a357600080fd5b506108c4600480360360208110156108ba57600080fd5b503560ff16611d7a565b604080516001600160a01b039092168252519081900360200190f35b3480156108ec57600080fd5b50610277611e02565b61028e6004803603606081101561090b57600080fd5b81019060208101813564010000000081111561092657600080fd5b82018360208201111561093857600080fd5b8035906020019184602083028401116401000000008311171561095a57600080fd5b919350915080359060200135611e7e565b6102776004803603602081101561098157600080fd5b5035612025565b34801561099457600080fd5b506108c461210b565b61028e600480360360a08110156109b357600080fd5b5060ff81358116916020810135909116906040810135906060810135906080013561211a565b3480156109e557600080fd5b5061028e600480360360208110156109fc57600080fd5b503560ff166122ba565b348015610a1257600080fd5b5061028e612339565b348015610a2757600080fd5b5061028e60048036036060811015610a3e57600080fd5b5060ff81358116916020810135909116906040013561235d565b348015610a6457600080fd5b506108c46123eb565b6102776004803603610100811015610a8457600080fd5b810190602081018135640100000000811115610a9f57600080fd5b820183602082011115610ab157600080fd5b80359060200191846020830284011164010000000083111715610ad357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610b2357600080fd5b820183602082011115610b3557600080fd5b80359060200191846020830284011164010000000083111715610b5757600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610ba757600080fd5b820183602082011115610bb957600080fd5b80359060200191846001830284011164010000000083111715610bdb57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050640100000000811115610c2e57600080fd5b820183602082011115610c4057600080fd5b80359060200191846001830284011164010000000083111715610c6257600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050823593505050602081013590604081013590606001356001600160a01b031661240f565b348015610cc957600080fd5b506108c46124f4565b610277612503565b348015610ce657600080fd5b5061028e6125fc565b348015610cfb57600080fd5b5061028e612650565b348015610d1057600080fd5b5061028e60048036036040811015610d2757600080fd5b810190602081018135640100000000811115610d4257600080fd5b820183602082011115610d5457600080fd5b80359060200191846020830284011164010000000083111715610d7657600080fd5b91935091503515156126ab565b348015610d8f57600080fd5b5061028e60048036036020811015610da657600080fd5b5035612747565b348015610db957600080fd5b506105b460048036036020811015610dd057600080fd5b50356127d5565b348015610de357600080fd5b5061027760048036036020811015610dfa57600080fd5b50356001600160a01b031661291f565b610e1261210b565b6001600160a01b0316336001600160a01b03161480610e3b575060d8546001600160a01b031633145b610e8c576040805162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f7420617574686f72697a65640000000000000000604482015290519081900360640190fd5b610eaa60c9610e9961210b565b60d8546001600160a01b0316612a4c565b565b600060c973__$a50a14a4f4d416df093fe8223c9bbe01e7$__63c9b64dcb90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610f0057600080fd5b505af4158015610f14573d6000803e3d6000fd5b505050506040513d6020811015610f2a57600080fd5b5051905090565b600054610100900460ff1680610f4a5750610f4a612bb3565b80610f58575060005460ff16155b610f935760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015610fbe576000805460ff1961ff0019909116610100171660011790555b610fcf8a8a8a8a8a8a8a8a8a612bc4565b610ff87f0000000000000000000000000000000000000000000000000000000000000000612f9c565b801561100a576000805461ff00191690555b50505050505050505050565b610eaa7f0000000000000000000000000000000000000000000000000000000000000000612f9c565b60d45460d55460d6546001600160a01b039092169183565b6060600260975414156110b1576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755814281101561110c576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6373fd6b3e90918888886040518563ffffffff1660e01b815260040180858152602001848152602001806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060006040518083038186803b15801561119d57600080fd5b505af41580156111b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405260208110156111f857600080fd5b810190808051604051939291908464010000000082111561121857600080fd5b90830190602082018581111561122d57600080fd5b825186602082028301116401000000008211171561124a57600080fd5b82525081516020918201928201910280838360005b8381101561127757818101518382015260200161125f565b505050509050016040525050509150506001609755949350505050565b604080517ff6ada8c200000000000000000000000000000000000000000000000000000000815260c9600482015260d460248201526044810184905260ff83166064820152905160009173__$aab211470864825841e17a6cd6f7ce977f$__9163f6ada8c291608480820192602092909190829003018186803b15801561131a57600080fd5b505af415801561132e573d6000803e3d6000fd5b505050506040513d602081101561134457600080fd5b505190505b92915050565b6113576130c9565b6001600160a01b031661136861210b565b6001600160a01b0316146113c3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f467e186c00000000000000000000000000000000000000000000000000000000815260c9600482015260248101839052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__9163467e186c916044808301926000929190829003018186803b15801561143557600080fd5b505af4158015611449573d6000803e3d6000fd5b5050505050565b6000600260975414156114aa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556114b761194f565b15611509576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b818042111561155f576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fc1a6627300000000000000000000000000000000000000000000000000000000815260c9600482015260d460248201526044810188905260ff8716606482015260848101869052905173__$aab211470864825841e17a6cd6f7ce977f$__9163c1a662739160a4808301926020929190829003018186803b1580156115e857600080fd5b505af41580156115fc573d6000803e3d6000fd5b505050506040513d602081101561161257600080fd5b505160016097559695505050505050565b61162b6130c9565b6001600160a01b031661163c61210b565b6001600160a01b031614611697576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610eaa6130cd565b6000600260975414156116f9576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561170661194f565b15611758576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b81804211156117ae576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b73__$aab211470864825841e17a6cd6f7ce977f$__63d1ab4b4a60c960d48989896040518663ffffffff1660e01b815260040180868152602001858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b1580156115e857600080fd5b61184e6130c9565b6001600160a01b031661185f61210b565b6001600160a01b0316146118ba576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f58fdd79b00000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260448101839052905173__$a50a14a4f4d416df093fe8223c9bbe01e7$__916358fdd79b916064808301926000929190829003018186803b15801561193357600080fd5b505af4158015611947573d6000803e3d6000fd5b505050505050565b60655460ff1690565b60c95460ca5460cb5460cc5460cd5460ce5460cf546001600160a01b031687565b6001600160a01b038116600081815260d36020526040812054909160ff909116906119a382611d7a565b6001600160a01b0316146119fe576040805162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f74206578697374000000000000000000000000604482015290519081900360640190fd5b90505b919050565b611a0e6130c9565b6001600160a01b0316611a1f61210b565b6001600160a01b031614611a7a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b604080517fd45757ba00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff80861660448301528416606482015260848101839052905160009173__$aab211470864825841e17a6cd6f7ce977f$__9163d45757ba9160a480820192602092909190829003018186803b158015611b6a57600080fd5b505af4158015611b7e573d6000803e3d6000fd5b505050506040513d6020811015611b9457600080fd5b505190505b9392505050565b600060026097541415611bfa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611c0761194f565b15611c59576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611caf576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517e80247a00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff808a166044830152881660648201526084810187905260a48101869052905173__$aab211470864825841e17a6cd6f7ce977f$__916280247a9160c4808301926020929190829003018186803b158015611d3e57600080fd5b505af4158015611d52573d6000803e3d6000fd5b505050506040513d6020811015611d6857600080fd5b50516001609755979650505050505050565b60d05460009060ff831610611dd6576040805162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e67650000000000000000000000000000000000000000604482015290519081900360640190fd5b60d0805460ff8416908110611de757fe5b6000918252602090912001546001600160a01b031692915050565b611e0a6130c9565b6001600160a01b0316611e1b61210b565b6001600160a01b031614611e76576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610eaa613176565b600060026097541415611ed8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611ee561194f565b15611f37576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611f8d576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b73__$aab211470864825841e17a6cd6f7ce977f$__637e97165660c960d48989896040518663ffffffff1660e01b815260040180868152602001858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b1580156115e857600080fd5b61202d6130c9565b6001600160a01b031661203e61210b565b6001600160a01b031614612099576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f7046727600000000000000000000000000000000000000000000000000000000815260c9600482015260248101839052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__916370467276916044808301926000929190829003018186803b15801561143557600080fd5b6033546001600160a01b031690565b600060026097541415612174576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561218161194f565b156121d3576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115612229576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517f98414eed00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff808a166044830152881660648201526084810187905260a48101869052905173__$aab211470864825841e17a6cd6f7ce977f$__916398414eed9160c4808301926020929190829003018186803b158015611d3e57600080fd5b60d05460009060ff831610612316576040805162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e67650000000000000000000000000000604482015290519081900360640190fd5b60d2805460ff841690811061232757fe5b90600052602060002001549050919050565b7f466565436f6c6c6563746f72000000000000000000000000000000000000000081565b604080517f5afb90ff00000000000000000000000000000000000000000000000000000000815260c9600482015260d4602482015260ff80861660448301528416606482015260848101839052905160009173__$aab211470864825841e17a6cd6f7ce977f$__91635afb90ff9160a480820192602092909190829003018186803b158015611b6a57600080fd5b7f000000000000000000000000000000000000000000000000000000000000000081565b600054610100900460ff16806124285750612428612bb3565b80612436575060005460ff16155b6124715760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff1615801561249c576000805460ff1961ff0019909116610100171660011790555b6040805162461bcd60e51b815260206004820181905260248201527f75736520696e697469616c697a654d65746153776170282920696e7374656164604482015290519081900360640190fd5b505050505050505050565b60d8546001600160a01b031681565b61250b6130c9565b6001600160a01b031661251c61210b565b6001600160a01b031614612577576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517ff14e211e00000000000000000000000000000000000000000000000000000000815260c96004820152905173__$a50a14a4f4d416df093fe8223c9bbe01e7$__9163f14e211e916024808301926000929190829003018186803b1580156125e257600080fd5b505af41580156125f6573d6000803e3d6000fd5b50505050565b600060c973__$a50a14a4f4d416df093fe8223c9bbe01e7$__63b0a14cfc90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610f0057600080fd5b600073__$aab211470864825841e17a6cd6f7ce977f$__63e9d4d07760c960d46040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015610f0057600080fd5b600073__$aab211470864825841e17a6cd6f7ce977f$__6378b0bcbe60c960d48787876040518663ffffffff1660e01b8152600401808681526020018581526020018060200183151581526020018281038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b158015611b6a57600080fd5b600060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__637d0481609091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156127a357600080fd5b505af41580156127b7573d6000803e3d6000fd5b505050506040513d60208110156127cd57600080fd5b505192915050565b606060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6370703e4a9091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561283157600080fd5b505af4158015612845573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052602081101561288c57600080fd5b81019080805160405193929190846401000000008211156128ac57600080fd5b9083019060208201858111156128c157600080fd5b82518660208202830111640100000000821117156128de57600080fd5b82525081516020918201928201910280838360005b8381101561290b5781810151838201526020016128f3565b505050509050016040525050509050919050565b6129276130c9565b6001600160a01b031661293861210b565b6001600160a01b031614612993576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166129d85760405162461bcd60e51b815260040180806020018281038252602681526020018061459b6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b606083600701805480602002602001604051908101604052809291908181526020018280548015612aa657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a88575b5050505050905060005b8151811015611449576000828281518110612ac757fe5b6020026020010151905060006002612b71886009018581548110612ae757fe5b9060005260206000200154846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612b3f57600080fd5b505afa158015612b53573d6000803e3d6000fd5b505050506040513d6020811015612b6957600080fd5b505190613206565b81612b7857fe5b0490508015612ba957612b956001600160a01b0383168783613263565b612ba96001600160a01b0383168683613263565b5050600101612ab0565b6000612bbe306132e8565b15905090565b600054610100900460ff1680612bdd5750612bdd612bb3565b80612beb575060005460ff16155b612c265760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015612c51576000805460ff1961ff0019909116610100171660011790555b612c618a8a8a8a8a8a8a8a6132ee565b60d480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038416908117909155604080517fe25aa5fa000000000000000000000000000000000000000000000000000000008152905163e25aa5fa91600480820192602092909190829003018186803b158015612ce657600080fd5b505afa158015612cfa573d6000803e3d6000fd5b505050506040513d6020811015612d1057600080fd5b505160d5554260d65560005b60208160ff161015612e3757826001600160a01b03166382b86600826040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b158015612d6f57600080fd5b505afa925050508015612d9457506040513d6020811015612d8f57600080fd5b505160015b612d9d57612e37565b60d780546001810182556000919091527f8a012a6de2943a5aa4d77acf5e695d4456760a3f1f30a5d6dc2079599187a0710180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155612e2e90857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff613ae9565b50600101612d1c565b60018160ff1611612e795760405162461bcd60e51b815260040180806020018281038252602481526020018061465a6024913960400191505060405180910390fd5b5060008a60018c510381518110612e8c57fe5b60200260200101519050826001600160a01b0316816001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ed957600080fd5b505afa158015612eed573d6000803e3d6000fd5b505050506040513d6020811015612f0357600080fd5b50516001600160a01b031614612f4a5760405162461bcd60e51b81526004018080602001828103825260248152602001806146156024913960400191505060405180910390fd5b612f7e6001600160a01b038216847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff613ae9565b50801561100a576000805461ff001916905550505050505050505050565b6000816001600160a01b0316633705f6257f466565436f6c6c6563746f72000000000000000000000000000000000000000060001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561300557600080fd5b505afa158015613019573d6000803e3d6000fd5b505050506040513d602081101561302f57600080fd5b505190506001600160a01b03811661308e576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b3390565b6130d561194f565b613126576040805162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6131596130c9565b604080516001600160a01b039092168252519081900360200190a1565b61317e61194f565b156131d0576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131596130c9565b60008282111561325d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526132e3908490613c3f565b505050565b3b151590565b600054610100900460ff16806133075750613307612bb3565b80613315575060005460ff16155b6133505760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff1615801561337b576000805460ff1961ff0019909116610100171660011790555b613383613cf0565b61338b613daa565b60018951116133e1576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d203100000000000000604482015290519081900360640190fd5b602089511115613438576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e20333200000000000000604482015290519081900360640190fd5b875189511461348e576040805162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d6174636800604482015290519081900360640190fd5b6060885167ffffffffffffffff811180156134a857600080fd5b506040519080825280602002602001820160405280156134d2578160200160208202803683370190505b50905060005b8a518160ff1610156137505760ff8116156135c15760d360008c8360ff168151811061350057fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff1615801561357057508a8160ff168151811061353e57fe5b60200260200101516001600160a01b03168b60008151811061355c57fe5b60200260200101516001600160a01b031614155b6135c1576040805162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e7300000000000000000000000000000000604482015290519081900360640190fd5b60006001600160a01b03168b8260ff16815181106135db57fe5b60200260200101516001600160a01b0316141561363f576040805162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d3230000000604482015290519081900360640190fd5b601260ff168a8260ff168151811061365357fe5b602002602001015160ff1611156136b1576040805162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d6178000000000000604482015290519081900360640190fd5b6136e18a8260ff16815181106136c357fe5b602002602001015160ff16601260ff1661320690919063ffffffff16565b600a0a828260ff16815181106136f357fe5b6020026020010181815250508060d360008d8460ff168151811061371357fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191660ff929092169190911790556001016134d8565b50620f424086106137a8576040805162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d0000000000000000000000000000604482015290519081900360640190fd5b6305f5e1008510613800576040805162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d000000000000000000000000604482015290519081900360640190fd5b6402540be4008410613859576040805162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d00000000000000604482015290519081900360640190fd5b600061386484613e3f565b9050806001600160a01b0316634cd88b768a8a6040518363ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019080838360005b838110156138c75781810151838201526020016138af565b50505050905090810190601f1680156138f45780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b8381101561392757818101518382015260200161390f565b50505050905090810190601f1680156139545780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561397557600080fd5b505af1158015613989573d6000803e3d6000fd5b505050506040513d602081101561399f57600080fd5b50516139f2576040805162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e6500000000604482015290519081900360640190fd5b60cf80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790558a51613a389060d09060208e019061448a565b508151613a4c9060d1906020850190614507565b508a5167ffffffffffffffff81118015613a6557600080fd5b50604051908082528060200260200182016040528015613a8f578160200160208202803683370190505b508051613aa49160d291602090910190614507565b50613ab0876064613efa565b60c955613abe876064613efa565b60ca55505060cd84905560ce83905580156124e9576000805461ff0019169055505050505050505050565b801580613b885750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015613b5a57600080fd5b505afa158015613b6e573d6000803e3d6000fd5b505050506040513d6020811015613b8457600080fd5b5051155b613bc35760405162461bcd60e51b81526004018080602001828103825260368152602001806146a86036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790526132e39084905b6060613c94826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f539092919063ffffffff16565b8051909150156132e357808060200190516020811015613cb357600080fd5b50516132e35760405162461bcd60e51b815260040180806020018281038252602a81526020018061467e602a913960400191505060405180910390fd5b600054610100900460ff1680613d095750613d09612bb3565b80613d17575060005460ff16155b613d525760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613d7d576000805460ff1961ff0019909116610100171660011790555b613d85613f6a565b613d8d61400a565b613d9561411b565b8015613da7576000805461ff00191690555b50565b600054610100900460ff1680613dc35750613dc3612bb3565b80613dd1575060005460ff16155b613e0c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613e37576000805460ff1961ff0019909116610100171660011790555b613d956141c6565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116611a01576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b600082613f0957506000611349565b82820282848281613f1657fe5b0414611b995760405162461bcd60e51b81526004018080602001828103825260218152602001806146396021913960400191505060405180910390fd5b6060613f62848460008561426c565b949350505050565b600054610100900460ff1680613f835750613f83612bb3565b80613f91575060005460ff16155b613fcc5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015613d95576000805460ff1961ff0019909116610100171660011790558015613da7576000805461ff001916905550565b600054610100900460ff16806140235750614023612bb3565b80614031575060005460ff16155b61406c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015614097576000805460ff1961ff0019909116610100171660011790555b60006140a16130c9565b603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015613da7576000805461ff001916905550565b600054610100900460ff16806141345750614134612bb3565b80614142575060005460ff16155b61417d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff161580156141a8576000805460ff1961ff0019909116610100171660011790555b6065805460ff191690558015613da7576000805461ff001916905550565b600054610100900460ff16806141df57506141df612bb3565b806141ed575060005460ff16155b6142285760405162461bcd60e51b815260040180806020018281038252602e8152602001806145e7602e913960400191505060405180910390fd5b600054610100900460ff16158015614253576000805460ff1961ff0019909116610100171660011790555b60016097558015613da7576000805461ff001916905550565b6060824710156142ad5760405162461bcd60e51b81526004018080602001828103825260268152602001806145c16026913960400191505060405180910390fd5b6142b6856132e8565b614307576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061436457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614327565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146143c6576040519150601f19603f3d011682016040523d82523d6000602084013e6143cb565b606091505b50915091506143db8282866143e6565b979650505050505050565b606083156143f5575081611b99565b8251156144055782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561444f578181015183820152602001614437565b50505050905090810190601f16801561447c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8280548282559060005260206000209081019282156144f7579160200282015b828111156144f757825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039091161782556020909201916001909101906144aa565b5061450392915061454e565b5090565b828054828255906000526020600020908101928215614542579160200282015b82811115614542578251825591602001919060010190614527565b50614503929150614585565b5b808211156145035780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161454f565b5b80821115614503576000815560010161458656fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564626173654c50546f6b656e206973206e6f74206f776e6564206279206261736553776170536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776261736553776170206d75737420706f6f6c206174206c65617374203220746f6b656e735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220c7695509f9aa5c890124f7995f1eb296fadfc0a22e319887a31f8bbc8a54d78a64736f6c634300060c0033", + "libraries": { + "SwapUtils": "0x4a5208f83a17e030a18830521e4064e80728c4fc", + "MetaSwapUtils": "0xfeEa4D1BacB0519E8f952460A70719944fe56Ee0", + "AmplificationUtils": "0xFdA5D2ad8b6d3884AbB799DA66f57175E8706941" + }, + "devdoc": { + "details": "Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's deployment size.", + "kind": "dev", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "deadline": "latest timestamp to accept this transaction", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation" + }, + "returns": { + "_0": "amount of LP token user minted and received" + } + }, + "calculateRemoveLiquidity(uint256)": { + "params": { + "amount": "the amount of LP tokens that would be burned on withdrawal" + }, + "returns": { + "_0": "array of token balances that the user will receive" + } + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "params": { + "tokenAmount": "the amount of LP token to burn", + "tokenIndex": "index of which token will be withdrawn" + }, + "returns": { + "_0": "availableTokenAmount calculated amount of underlying token available to withdraw" + } + }, + "calculateSwap(uint8,uint8,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of tokens the user will receive" + } + }, + "calculateSwapUnderlying(uint8,uint8,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of tokens the user will receive" + } + }, + "calculateTokenAmount(uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal" + }, + "returns": { + "_0": "token amount the user will receive" + } + }, + "constructor": { + "params": { + "_masterRegistry": "address of the MasterRegistry contract" + } + }, + "getA()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter" + } + }, + "getAPrecise()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter in its raw precision form" + } + }, + "getAdminBalance(uint256)": { + "params": { + "index": "Index of the pooled token" + }, + "returns": { + "_0": "admin's token balance in the token's precision" + } + }, + "getToken(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "address of the token at given index" + } + }, + "getTokenBalance(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "current balance of the pooled token at given index with token's native precision" + } + }, + "getTokenIndex(address)": { + "params": { + "tokenAddress": "address of the token" + }, + "returns": { + "_0": "the index of the given token address" + } + }, + "getVirtualPrice()": { + "returns": { + "_0": "the virtual price, scaled to the POOL_PRECISION_DECIMALS" + } + }, + "initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)": { + "params": { + "_a": "the amplification coefficient * n * (n - 1). See the StableSwap paper for details", + "_adminFee": "default adminFee to be initialized with", + "_fee": "default swap fee to be initialized with", + "_pooledTokens": "an array of ERC20s this pool will accept", + "decimals": "the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS", + "lpTokenName": "the long-form name of the token to be deployed", + "lpTokenSymbol": "the short symbol for the token to be deployed" + } + }, + "initializeMetaSwap(address[],uint8[],string,string,uint256,uint256,uint256,address,address)": { + "params": { + "_a": "the amplification coefficient * n * (n - 1). See the StableSwap paper for details", + "_adminFee": "default adminFee to be initialized with", + "_fee": "default swap fee to be initialized with", + "_pooledTokens": "an array of ERC20s this pool will accept. The last element must be an existing Swap pool's LP token's address.", + "decimals": "the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS", + "lpTokenName": "the long-form name of the token to be deployed", + "lpTokenSymbol": "the short symbol for the token to be deployed" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "rampA(uint256,uint256)": { + "params": { + "futureA": "the new A to ramp towards", + "futureTime": "timestamp when the new A should be reached" + } + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "details": "Liquidity can always be removed, even when the pool is paused.", + "params": { + "amount": "the amount of LP tokens to burn", + "deadline": "latest timestamp to accept this transaction", + "minAmounts": "the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation" + }, + "returns": { + "_0": "amounts of tokens user received" + } + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "deadline": "latest timestamp to accept this transaction", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation." + }, + "returns": { + "_0": "amount of LP tokens burned" + } + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "minAmount": "the minimum amount to withdraw, otherwise revert", + "tokenAmount": "the amount of the token you want to receive", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount of chosen token user received" + } + }, + "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." + }, + "setAdminFee(uint256)": { + "params": { + "newAdminFee": "new admin fee to be applied on future transactions" + } + }, + "setSwapFee(uint256)": { + "params": { + "newSwapFee": "new swap fee to be applied on future transactions" + } + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "dx": "the amount of tokens the user wants to swap from", + "minDy": "the min amount the user would like to receive, or revert.", + "tokenIndexFrom": "the token the user wants to swap from", + "tokenIndexTo": "the token the user wants to swap to" + } + }, + "swapUnderlying(uint8,uint8,uint256,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "dx": "the amount of tokens the user wants to swap from", + "minDy": "the min amount the user would like to receive, or revert.", + "tokenIndexFrom": "the token the user wants to swap from", + "tokenIndexTo": "the token the user wants to swap to" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "MetaSwap - A StableSwap implementation in solidity.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "notice": "Add liquidity to the pool with the given amounts of tokens" + }, + "calculateRemoveLiquidity(uint256)": { + "notice": "A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens" + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "notice": "Calculate the amount of underlying token available to withdraw when withdrawing via only single token" + }, + "calculateSwap(uint8,uint8,uint256)": { + "notice": "Calculate amount of tokens you receive on swap" + }, + "calculateSwapUnderlying(uint8,uint8,uint256)": { + "notice": "Calculate amount of tokens you receive on swap. For this function, the token indices are flattened out so that underlying tokens are represented." + }, + "calculateTokenAmount(uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running" + }, + "constructor": "Constructor for the PermissionlessSwap contract.", + "getA()": { + "notice": "Return A, the amplification coefficient * n * (n - 1)" + }, + "getAPrecise()": { + "notice": "Return A in its raw precision form" + }, + "getAdminBalance(uint256)": { + "notice": "This function reads the accumulated amount of admin fees of the token with given index" + }, + "getToken(uint8)": { + "notice": "Return address of the pooled token at given index. Reverts if tokenIndex is out of range." + }, + "getTokenBalance(uint8)": { + "notice": "Return current balance of the pooled token at given index" + }, + "getTokenIndex(address)": { + "notice": "Return the index of the given token address. Reverts if no matching token is found." + }, + "getVirtualPrice()": { + "notice": "Get the virtual price, to help calculate profit" + }, + "initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)": { + "notice": "This overrides Swap's initialize function to prevent initializing without the address of the base Swap contract." + }, + "initializeMetaSwap(address[],uint8[],string,string,uint256,uint256,uint256,address,address)": { + "notice": "Initializes this MetaSwap contract with the given parameters. MetaSwap uses an existing Swap pool to expand the available liquidity. _pooledTokens array should contain the base Swap pool's LP token as the last element. For example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] as _pooledTokens. This will also deploy the LPToken that represents users' LP position. The owner of LPToken will be this contract - which means only this contract is allowed to mint new tokens." + }, + "pause()": { + "notice": "Pause the contract. Revert if already paused." + }, + "rampA(uint256,uint256)": { + "notice": "Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range." + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "notice": "Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "notice": "Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "setAdminFee(uint256)": { + "notice": "Update the admin fee. Admin fee takes portion of the swap fee." + }, + "setSwapFee(uint256)": { + "notice": "Update the swap fee to be applied on swaps" + }, + "stopRampA()": { + "notice": "Stop ramping A immediately. Reverts if ramp A is already stopped." + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "notice": "Swap two tokens using this pool" + }, + "swapUnderlying(uint8,uint8,uint256,uint256,uint256)": { + "notice": "Swap two tokens using this pool and the base pool." + }, + "unpause()": { + "notice": "Unpause the contract. Revert if already unpaused." + }, + "updateFeeCollectorCache()": { + "notice": "Updates cached address of the fee collector" + }, + "withdrawAdminFees()": { + "notice": "Withdraw all admin fees to the contract owner and the fee collector" + } + }, + "notice": "This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws. MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens. As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD. Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case, `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 492, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 495, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1531, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 10, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 129, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1553, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool" + }, + { + "astId": 1644, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1659, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "_status", + "offset": 0, + "slot": "151", + "type": "t_uint256" + }, + { + "astId": 1702, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 7779, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "swapStorage", + "offset": 0, + "slot": "201", + "type": "t_struct(Swap)9655_storage" + }, + { + "astId": 7783, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "tokenIndexes", + "offset": 0, + "slot": "211", + "type": "t_mapping(t_address,t_uint8)" + }, + { + "astId": 26643, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "metaSwapStorage", + "offset": 0, + "slot": "212", + "type": "t_struct(MetaSwap)28772_storage" + }, + { + "astId": 33360, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "feeCollector", + "offset": 0, + "slot": "216", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_contract(IERC20)3311)dyn_storage": { + "base": "t_contract(IERC20)3311", + "encoding": "dynamic_array", + "label": "contract IERC20[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_array(t_uint256)dyn_storage": { + "base": "t_uint256", + "encoding": "dynamic_array", + "label": "uint256[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)3311": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(ISwap)25272": { + "encoding": "inplace", + "label": "contract ISwap", + "numberOfBytes": "20" + }, + "t_contract(LPToken)7402": { + "encoding": "inplace", + "label": "contract LPToken", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint8)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint8)", + "numberOfBytes": "32", + "value": "t_uint8" + }, + "t_struct(MetaSwap)28772_storage": { + "encoding": "inplace", + "label": "struct MetaSwapUtils.MetaSwap", + "members": [ + { + "astId": 28764, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "baseSwap", + "offset": 0, + "slot": "0", + "type": "t_contract(ISwap)25272" + }, + { + "astId": 28766, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "baseVirtualPrice", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 28768, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "baseCacheLastUpdated", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 28771, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "baseTokens", + "offset": 0, + "slot": "3", + "type": "t_array(t_contract(IERC20)3311)dyn_storage" + } + ], + "numberOfBytes": "128" + }, + "t_struct(Swap)9655_storage": { + "encoding": "inplace", + "label": "struct SwapUtils.Swap", + "members": [ + { + "astId": 9633, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "initialA", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 9635, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "futureA", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 9637, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "initialATime", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 9639, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "futureATime", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 9641, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "swapFee", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 9643, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "adminFee", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 9645, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "lpToken", + "offset": 0, + "slot": "6", + "type": "t_contract(LPToken)7402" + }, + { + "astId": 9648, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "pooledTokens", + "offset": 0, + "slot": "7", + "type": "t_array(t_contract(IERC20)3311)dyn_storage" + }, + { + "astId": 9651, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "tokenPrecisionMultipliers", + "offset": 0, + "slot": "8", + "type": "t_array(t_uint256)dyn_storage" + }, + { + "astId": 9654, + "contract": "contracts/permissionless/PermissionlessMetaSwap.sol:PermissionlessMetaSwap", + "label": "balances", + "offset": 0, + "slot": "9", + "type": "t_array(t_uint256)dyn_storage" + } + ], + "numberOfBytes": "320" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/PermissionlessSwapV1.json b/deployments/base_testnet/PermissionlessSwapV1.json new file mode 100644 index 00000000..7cda8e0e --- /dev/null +++ b/deployments/base_testnet/PermissionlessSwapV1.json @@ -0,0 +1,1486 @@ +{ + "address": "0xDCA5b16A96f984ffb2A3022cfF339eb049126101", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IMasterRegistry", + "name": "_masterRegistry", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "AddLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "NewSwapFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newWithdrawFee", + "type": "uint256" + } + ], + "name": "NewWithdrawFee", + "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": "uint256", + "name": "oldA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "initialTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "RampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidityImbalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "boughtId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + } + ], + "name": "RemoveLiquidityOne", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "StopRampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "FEE_COLLECTOR_NAME", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MASTER_REGISTRY", + "outputs": [ + { + "internalType": "contract IMasterRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "minToMint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "calculateRemoveLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + } + ], + "name": "calculateRemoveLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "availableTokenAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + } + ], + "name": "calculateSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "calculateTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeCollector", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getA", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAPrecise", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAdminBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getTokenBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "name": "getTokenIndex", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVirtualPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "_pooledTokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "lpTokenTargetAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "rampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxBurnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityImbalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "minAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "setAdminFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "setSwapFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "stopRampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minDy", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "swapStorage", + "outputs": [ + { + "internalType": "uint256", + "name": "initialA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "contract LPToken", + "name": "lpToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateFeeCollectorCache", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAdminFees", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x589605338195299a33d07fd35d09a5d8d096f1fe7f222303cfaf0de78fd3c851", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xDCA5b16A96f984ffb2A3022cfF339eb049126101", + "transactionIndex": 1, + "gasUsed": "3311778", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x1365df9329e816a68850d37164bf46e299996412d544a637ff0e649a8510ef0d", + "transactionHash": "0x589605338195299a33d07fd35d09a5d8d096f1fe7f222303cfaf0de78fd3c851", + "logs": [], + "blockNumber": 2717070, + "cumulativeGasUsed": "3311778", + "status": 1, + "byzantium": true + }, + "args": ["0x9cDeF6e33687F438808766fC133b2E9d1A16AD57"], + "numDeployments": 1, + "solcInputHash": "bc3a64a5cffb1e8de0dbf9fb306e4f9f", + "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IMasterRegistry\",\"name\":\"_masterRegistry\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"NewSwapFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newWithdrawFee\",\"type\":\"uint256\"}],\"name\":\"NewWithdrawFee\",\"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\":\"uint256\",\"name\":\"oldA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialTime\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"RampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityImbalance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"boughtId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityOne\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"currentA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"}],\"name\":\"StopRampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwap\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FEE_COLLECTOR_NAME\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MASTER_REGISTRY\",\"outputs\":[{\"internalType\":\"contract IMasterRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"minToMint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateRemoveLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"}],\"name\":\"calculateRemoveLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"availableTokenAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"}],\"name\":\"calculateSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"calculateTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeCollector\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPrecise\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getAdminBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getTokenBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"}],\"name\":\"getTokenIndex\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVirtualPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"_pooledTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"lpTokenTargetAddress\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"rampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"minAmounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"maxBurnAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityImbalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"minAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"setAdminFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"setSwapFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stopRampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDy\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapStorage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"initialA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initialATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"contract LPToken\",\"name\":\"lpToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"updateFeeCollectorCache\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawAdminFees\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Most of the logic is stored as a library `PermissionlessSwapUtils` for the sake of reducing contract's deployment size.\",\"kind\":\"dev\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"deadline\":\"latest timestamp to accept this transaction\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation\"},\"returns\":{\"_0\":\"amount of LP token user minted and received\"}},\"calculateRemoveLiquidity(uint256)\":{\"params\":{\"amount\":\"the amount of LP tokens that would be burned on withdrawal\"},\"returns\":{\"_0\":\"array of token balances that the user will receive\"}},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"params\":{\"tokenAmount\":\"the amount of LP token to burn\",\"tokenIndex\":\"index of which token will be withdrawn\"},\"returns\":{\"availableTokenAmount\":\"calculated amount of underlying token available to withdraw\"}},\"calculateSwap(uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of tokens the user will receive\"}},\"calculateTokenAmount(uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\"},\"returns\":{\"_0\":\"token amount the user will receive\"}},\"constructor\":{\"params\":{\"_masterRegistry\":\"address of the MasterRegistry contract\"}},\"getA()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter\"}},\"getAPrecise()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter in its raw precision form\"}},\"getAdminBalance(uint256)\":{\"params\":{\"index\":\"Index of the pooled token\"},\"returns\":{\"_0\":\"admin's token balance in the token's precision\"}},\"getToken(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"address of the token at given index\"}},\"getTokenBalance(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"current balance of the pooled token at given index with token's native precision\"}},\"getTokenIndex(address)\":{\"params\":{\"tokenAddress\":\"address of the token\"},\"returns\":{\"_0\":\"the index of the given token address\"}},\"getVirtualPrice()\":{\"returns\":{\"_0\":\"the virtual price, scaled to the POOL_PRECISION_DECIMALS\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"rampA(uint256,uint256)\":{\"params\":{\"futureA\":\"the new A to ramp towards\",\"futureTime\":\"timestamp when the new A should be reached\"}},\"removeLiquidity(uint256,uint256[],uint256)\":{\"details\":\"Liquidity can always be removed, even when the pool is paused.\",\"params\":{\"amount\":\"the amount of LP tokens to burn\",\"deadline\":\"latest timestamp to accept this transaction\",\"minAmounts\":\"the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation\"},\"returns\":{\"_0\":\"amounts of tokens user received\"}},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"deadline\":\"latest timestamp to accept this transaction\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\"},\"returns\":{\"_0\":\"amount of LP tokens burned\"}},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"tokenAmount\":\"the amount of the token you want to receive\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount of chosen token user received\"}},\"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.\"},\"setAdminFee(uint256)\":{\"params\":{\"newAdminFee\":\"new admin fee to be applied on future transactions\"}},\"setSwapFee(uint256)\":{\"params\":{\"newSwapFee\":\"new swap fee to be applied on future transactions\"}},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"dx\":\"the amount of tokens the user wants to swap from\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"tokenIndexFrom\":\"the token the user wants to swap from\",\"tokenIndexTo\":\"the token the user wants to swap to\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Swap - A StableSwap implementation in solidity.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"notice\":\"Add liquidity to the pool with the given amounts of tokens\"},\"calculateRemoveLiquidity(uint256)\":{\"notice\":\"A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens\"},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"notice\":\"Calculate the amount of underlying token available to withdraw when withdrawing via only single token\"},\"calculateSwap(uint8,uint8,uint256)\":{\"notice\":\"Calculate amount of tokens you receive on swap\"},\"calculateTokenAmount(uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running\"},\"constructor\":\"Constructor for the PermissionlessSwap contract.\",\"getA()\":{\"notice\":\"Return A, the amplification coefficient * n * (n - 1)\"},\"getAPrecise()\":{\"notice\":\"Return A in its raw precision form\"},\"getAdminBalance(uint256)\":{\"notice\":\"This function reads the accumulated amount of admin fees of the token with given index\"},\"getToken(uint8)\":{\"notice\":\"Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\"},\"getTokenBalance(uint8)\":{\"notice\":\"Return current balance of the pooled token at given index\"},\"getTokenIndex(address)\":{\"notice\":\"Return the index of the given token address. Reverts if no matching token is found.\"},\"getVirtualPrice()\":{\"notice\":\"Get the virtual price, to help calculate profit\"},\"initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)\":{\"notice\":\"Updates cached address of the fee collector\"},\"pause()\":{\"notice\":\"Pause the contract. Revert if already paused.\"},\"rampA(uint256,uint256)\":{\"notice\":\"Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range.\"},\"removeLiquidity(uint256,uint256[],uint256)\":{\"notice\":\"Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"setAdminFee(uint256)\":{\"notice\":\"Update the admin fee. Admin fee takes portion of the swap fee.\"},\"setSwapFee(uint256)\":{\"notice\":\"Update the swap fee to be applied on swaps\"},\"stopRampA()\":{\"notice\":\"Stop ramping A immediately. Reverts if ramp A is already stopped.\"},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"notice\":\"Swap two tokens using this pool\"},\"unpause()\":{\"notice\":\"Unpause the contract. Revert if already unpaused.\"},\"updateFeeCollectorCache()\":{\"notice\":\"Updates cached address of the fee collector\"},\"withdrawAdminFees()\":{\"notice\":\"Withdraw all admin fees to the contract owner and the fee collector.\"}},\"notice\":\"This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. Part of this fee is given to the creator of the pool as an Admin fee, the amount of which is set when the pool is created. Saddle will collect to 50% of these Admin fees. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/permissionless/PermissionlessSwap.sol\":\"PermissionlessSwap\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/Initializable.sol\\\";\\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 initializer {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal initializer {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xb419e68addcb82ecda3ad3974b0d2db76435ce9b08435a04d5b119a0c5d45ea5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMathUpgradeable {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x0dd1e9b19801e3e7d900fbf4182d81e1afd23ad7be39504e33df6bbcba91d724\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-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 */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd8e4eb08dcc1d1860fb347ba5ffd595242b9a1b66d49a47f2b4cb51c3f35017e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./ERC20Upgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal initializer {\\n __Context_init_unchained();\\n __ERC20Burnable_init_unchained();\\n }\\n\\n function __ERC20Burnable_init_unchained() internal initializer {\\n }\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \\\"ERC20: burn amount exceeds allowance\\\");\\n\\n _approve(account, _msgSender(), decreasedAllowance);\\n _burn(account, amount);\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xd0359e87fe2618573f49a95e13d9dbc31521ad64526b135618abb2a2dc362fbe\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"../../math/SafeMathUpgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n uint256[44] private __gap;\\n}\\n\",\"keccak256\":\"0x506dd0718f9ace50588c13848167df5e04ae16abb56341afb10c31ff149bc79b\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xa1931c47a617014f858580db625aa0dcf343796f39acd4b5b51effc092a1f0a9\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary 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 function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfc5ea91fa9ceb1961023b2a6c978b902888c52b90847ac7813fe3b79524165f6\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/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 GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal initializer {\\n __Context_init_unchained();\\n }\\n\\n function __Context_init_unchained() internal initializer {\\n }\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xbbf8a21b9a66c48d45ff771b8563c6df19ba451d63dfb8380a865c1e1f29d1a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/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 initializer {\\n __Context_init_unchained();\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal initializer {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n require(!paused(), \\\"Pausable: paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n require(paused(), \\\"Pausable: not paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x73bef0a5dec3efde8183c4858d90f683ed2771656c4329647b4d5b0f89498fd5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuardUpgradeable is Initializable {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n function __ReentrancyGuard_init() internal initializer {\\n __ReentrancyGuard_init_unchained();\\n }\\n\\n function __ReentrancyGuard_init_unchained() internal initializer {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x46034cd5cca740f636345c8f7aebae0f78adfd4b70e31e6f888cccbe1086586e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xcc78a17dd88fa5a2edc60c8489e2f405c0913b377216a5b26b35656b2d0dab52\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address master) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `master` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, master))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\\n return predictDeterministicAddress(master, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0x0d24348f536f928d8b42789737bf34762faee065667ab530ea20969a9d9920d1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) public {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0xca0c2396dbeb3503b51abf4248ebf77a1461edad513c01529df51850a012bee3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.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 SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) 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(IERC20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require((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(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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) { // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf12dfbe97e6276980b83d2830bb0eb75e0cf4f3e626c2471137f82158ae6a0fc\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"contracts/AmplificationUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"./SwapUtils.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtils.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtils {\\n using SafeMath for uint256;\\n\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtils.Swap storage self) external view returns (uint256) {\\n return _getAPrecise(self).div(A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtils.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtils.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return\\n a0.add(\\n a1.sub(a0).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\\n );\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return\\n a0.sub(\\n a0.sub(a1).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\\n );\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtils.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= self.initialATime.add(1 days),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= block.timestamp.add(MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_.mul(A_PRECISION);\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n futureAPrecise.mul(MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= initialAPrecise.mul(MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtils.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0x454f7c599a980fc449ff0f21dee10922262193134ea709f3be50c9d44a7d5385\",\"license\":\"MIT\"},\"contracts/LPToken.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwap.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPToken is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8b16a37e14fd2d387dac20bf1773522b7667402f27a4b301617b928d7b998ac5\",\"license\":\"MIT\"},\"contracts/MathUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtils {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x455c798b26b679dff11a4ad5d52f7fef85c42d403bd430da443948f65cf000a0\",\"license\":\"MIT\"},\"contracts/OwnerPausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\\\";\\n\\n/**\\n * @title OwnerPausable\\n * @notice An ownable contract allows the owner to pause and unpause the\\n * contract without a delay.\\n * @dev Only methods using the provided modifiers will be paused.\\n */\\nabstract contract OwnerPausableUpgradeable is\\n OwnableUpgradeable,\\n PausableUpgradeable\\n{\\n function __OwnerPausable_init() internal initializer {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n __Pausable_init_unchained();\\n }\\n\\n /**\\n * @notice Pause the contract. Revert if already paused.\\n */\\n function pause() external onlyOwner {\\n PausableUpgradeable._pause();\\n }\\n\\n /**\\n * @notice Unpause the contract. Revert if already unpaused.\\n */\\n function unpause() external onlyOwner {\\n PausableUpgradeable._unpause();\\n }\\n}\\n\",\"keccak256\":\"0xe8d79072ff7e9ec0ade50d81be8681a9fedfabe7b3d3de116e83cb7f4e1446f6\",\"license\":\"MIT\"},\"contracts/Swap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/proxy/Clones.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\\\";\\nimport \\\"./OwnerPausableUpgradeable.sol\\\";\\nimport \\\"./SwapUtils.sol\\\";\\nimport \\\"./AmplificationUtils.sol\\\";\\n\\n/**\\n * @title Swap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\\n * deployment size.\\n */\\ncontract Swap is OwnerPausableUpgradeable, ReentrancyGuardUpgradeable {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n using SwapUtils for SwapUtils.Swap;\\n using AmplificationUtils for SwapUtils.Swap;\\n\\n // Struct storing data responsible for automatic market maker functionalities. In order to\\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtils.sol\\n SwapUtils.Swap public swapStorage;\\n\\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\\n // getTokenIndex function also relies on this mapping to retrieve token index.\\n mapping(address => uint8) private tokenIndexes;\\n\\n /*** EVENTS ***/\\n\\n // events replicated from SwapUtils to make the ABI easier for dumb\\n // clients\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n event NewWithdrawFee(uint256 newWithdrawFee);\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n /**\\n * @notice Initializes this Swap contract with the given parameters.\\n * This will also clone a LPToken contract that represents users'\\n * LP positions. The owner of LPToken will be this contract - which means\\n * only this contract is allowed to mint/burn tokens.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual initializer {\\n __OwnerPausable_init();\\n __ReentrancyGuard_init();\\n // Check _pooledTokens and precisions parameter\\n require(_pooledTokens.length > 1, \\\"_pooledTokens.length <= 1\\\");\\n require(_pooledTokens.length <= 32, \\\"_pooledTokens.length > 32\\\");\\n require(\\n _pooledTokens.length == decimals.length,\\n \\\"_pooledTokens decimals mismatch\\\"\\n );\\n\\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\\n\\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\\n if (i > 0) {\\n // Check if index is already used. Check if 0th element is a duplicate.\\n require(\\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\\n _pooledTokens[0] != _pooledTokens[i],\\n \\\"Duplicate tokens\\\"\\n );\\n }\\n require(\\n address(_pooledTokens[i]) != address(0),\\n \\\"The 0 address isn't an ERC-20\\\"\\n );\\n require(\\n decimals[i] <= SwapUtils.POOL_PRECISION_DECIMALS,\\n \\\"Token decimals exceeds max\\\"\\n );\\n precisionMultipliers[i] =\\n 10 **\\n uint256(SwapUtils.POOL_PRECISION_DECIMALS).sub(\\n uint256(decimals[i])\\n );\\n tokenIndexes[address(_pooledTokens[i])] = i;\\n }\\n\\n // Check _a, _fee, _adminFee, _withdrawFee parameters\\n require(_a < AmplificationUtils.MAX_A, \\\"_a exceeds maximum\\\");\\n require(_fee < SwapUtils.MAX_SWAP_FEE, \\\"_fee exceeds maximum\\\");\\n require(\\n _adminFee < SwapUtils.MAX_ADMIN_FEE,\\n \\\"_adminFee exceeds maximum\\\"\\n );\\n\\n // Clone and initialize a LPToken contract\\n LPToken lpToken = LPToken(Clones.clone(lpTokenTargetAddress));\\n require(\\n lpToken.initialize(lpTokenName, lpTokenSymbol),\\n \\\"could not init lpToken clone\\\"\\n );\\n\\n // Initialize swapStorage struct\\n swapStorage.lpToken = lpToken;\\n swapStorage.pooledTokens = _pooledTokens;\\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\\n swapStorage.balances = new uint256[](_pooledTokens.length);\\n swapStorage.initialA = _a.mul(AmplificationUtils.A_PRECISION);\\n swapStorage.futureA = _a.mul(AmplificationUtils.A_PRECISION);\\n // swapStorage.initialATime = 0;\\n // swapStorage.futureATime = 0;\\n swapStorage.swapFee = _fee;\\n swapStorage.adminFee = _adminFee;\\n }\\n\\n /*** MODIFIERS ***/\\n\\n /**\\n * @notice Modifier to check deadline against current timestamp\\n * @param deadline latest timestamp to accept this transaction\\n */\\n modifier deadlineCheck(uint256 deadline) {\\n require(block.timestamp <= deadline, \\\"Deadline not met\\\");\\n _;\\n }\\n\\n /*** VIEW FUNCTIONS ***/\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @return A parameter\\n */\\n function getA() external view virtual returns (uint256) {\\n return swapStorage.getA();\\n }\\n\\n /**\\n * @notice Return A in its raw precision form\\n * @dev See the StableSwap paper for details\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise() external view virtual returns (uint256) {\\n return swapStorage.getAPrecise();\\n }\\n\\n /**\\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\\n * @param index the index of the token\\n * @return address of the token at given index\\n */\\n function getToken(uint8 index) public view virtual returns (IERC20) {\\n require(index < swapStorage.pooledTokens.length, \\\"Out of range\\\");\\n return swapStorage.pooledTokens[index];\\n }\\n\\n /**\\n * @notice Return the index of the given token address. Reverts if no matching\\n * token is found.\\n * @param tokenAddress address of the token\\n * @return the index of the given token address\\n */\\n function getTokenIndex(address tokenAddress)\\n public\\n view\\n virtual\\n returns (uint8)\\n {\\n uint8 index = tokenIndexes[tokenAddress];\\n require(\\n address(getToken(index)) == tokenAddress,\\n \\\"Token does not exist\\\"\\n );\\n return index;\\n }\\n\\n /**\\n * @notice Return current balance of the pooled token at given index\\n * @param index the index of the token\\n * @return current balance of the pooled token at given index with token's native precision\\n */\\n function getTokenBalance(uint8 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n require(index < swapStorage.pooledTokens.length, \\\"Index out of range\\\");\\n return swapStorage.balances[index];\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice() external view virtual returns (uint256) {\\n return swapStorage.getVirtualPrice();\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view virtual returns (uint256) {\\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.calculateTokenAmount(amounts, deposit);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of LP tokens\\n * @param amount the amount of LP tokens that would be burned on withdrawal\\n * @return array of token balances that the user will receive\\n */\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n virtual\\n returns (uint256[] memory)\\n {\\n return swapStorage.calculateRemoveLiquidity(amount);\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view virtual returns (uint256 availableTokenAmount) {\\n return swapStorage.calculateWithdrawOneToken(tokenAmount, tokenIndex);\\n }\\n\\n /**\\n * @notice This function reads the accumulated amount of admin fees of the token with given index\\n * @param index Index of the pooled token\\n * @return admin's token balance in the token's precision\\n */\\n function getAdminBalance(uint256 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.getAdminBalance(index);\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice Swap two tokens using this pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.addLiquidity(amounts, minToMint);\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amounts of tokens user received\\n */\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n deadlineCheck(deadline)\\n returns (uint256[] memory)\\n {\\n return swapStorage.removeLiquidity(amount, minAmounts);\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n swapStorage.removeLiquidityOneToken(\\n tokenAmount,\\n tokenIndex,\\n minAmount\\n );\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\\n }\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner\\n */\\n function withdrawAdminFees() external payable virtual onlyOwner {\\n swapStorage.withdrawAdminFees(owner());\\n }\\n\\n /**\\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(uint256 newAdminFee) external payable onlyOwner {\\n swapStorage.setAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice Update the swap fee to be applied on swaps\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(uint256 newSwapFee) external payable onlyOwner {\\n swapStorage.setSwapFee(newSwapFee);\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param futureA the new A to ramp towards\\n * @param futureTime timestamp when the new A should be reached\\n */\\n function rampA(uint256 futureA, uint256 futureTime)\\n external\\n payable\\n onlyOwner\\n {\\n swapStorage.rampA(futureA, futureTime);\\n }\\n\\n /**\\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\\n */\\n function stopRampA() external payable onlyOwner {\\n swapStorage.stopRampA();\\n }\\n}\\n\",\"keccak256\":\"0x85aed3b11967ea0195717a6777a5e58ee9cc96f94e6992af002720f2b626840b\",\"license\":\"MIT\"},\"contracts/SwapUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtils.sol\\\";\\nimport \\\"./LPToken.sol\\\";\\nimport \\\"./MathUtils.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtils {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n using MathUtils for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPToken lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPToken lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtils._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = currentY\\n .sub(newY)\\n .div(self.tokenPrecisionMultipliers[tokenIndex])\\n .sub(dy);\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] = xpi.sub(\\n (\\n (i == tokenIndex)\\n ? xpi.mul(v.d1).div(v.d0).sub(v.newY)\\n : xpi.sub(xpi.mul(v.d1).div(v.d0))\\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\\n );\\n }\\n\\n uint256 dy = xpReduced[tokenIndex].sub(\\n getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\\n );\\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a.mul(numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s.add(xp[i]);\\n c = c.mul(d).div(xp[i].mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\\n\\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s.add(xp[i]);\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a.mul(numTokens);\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = dP.mul(d).div(xp[j].mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d = nA\\n .mul(s)\\n .div(AmplificationUtils.A_PRECISION)\\n .add(dP.mul(numTokens))\\n .mul(d)\\n .div(\\n nA\\n .sub(AmplificationUtils.A_PRECISION)\\n .mul(d)\\n .div(AmplificationUtils.A_PRECISION)\\n .add(numTokens.add(1).mul(dP))\\n );\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i].mul(precisionMultipliers[i]);\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPToken lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return d.mul(10**uint256(POOL_PRECISION_DECIMALS)).div(supply);\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens.mul(preciseA);\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s.add(_x);\\n c = c.mul(d).div(_x.mul(numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx.mul(multipliers[tokenIndexFrom]).add(xp[tokenIndexFrom]);\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo].sub(y).sub(1);\\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\\n dy = dy.sub(dyFee).div(multipliers[tokenIndexTo]);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = balances[i].mul(amount).div(totalSupply);\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i].add(amounts[i]);\\n } else {\\n balances[i] = balances[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return d1.sub(d0).mul(totalSupply).div(d0);\\n } else {\\n return d0.sub(d1).mul(totalSupply).div(d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)).sub(\\n self.balances[index]\\n );\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return swapFee.mul(numTokens).div(numTokens.sub(1).mul(4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)).sub(beforeBalance);\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\\n self.tokenPrecisionMultipliers[tokenIndexTo]\\n );\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom].add(dx);\\n self.balances[tokenIndexTo] = balances[tokenIndexTo].sub(dy).sub(\\n dyAdminFee\\n );\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\\n beforeBalance\\n );\\n }\\n\\n newBalances[i] = v.balances[i].add(amounts[i]);\\n }\\n\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\\n fees[i] = feePerToken\\n .mul(idealBalance.difference(newBalances[i]))\\n .div(FEE_DENOMINATOR);\\n self.balances[i] = newBalances[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n newBalances[i] = newBalances[i].sub(fees[i]);\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.add(toMint)\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPToken lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i].sub(amounts[i]);\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply.sub(amount));\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPToken lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\\n );\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n balances1[i] = v.balances[i].sub(\\n amounts[i],\\n \\\"Cannot withdraw more than available\\\"\\n );\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\\n self.balances[i] = balances1[i].sub(\\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\\n );\\n balances1[i] = balances1[i].sub(fees[i]);\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount.add(1);\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply.sub(tokenAmount)\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)).sub(\\n self.balances[i]\\n );\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0x1571bb987f110239e647da76403b6a73b7a46a082035dc950ddc9db26eb0fbed\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlist.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\ninterface IAllowlist {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xf55e4d678d05bc5d0e24ec5f24504d7437b885e19579f9d29152748c3c1c732e\",\"license\":\"MIT\"},\"contracts/interfaces/IMasterRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\ninterface IMasterRegistry {\\n /* Structs */\\n\\n struct ReverseRegistryData {\\n bytes32 name;\\n uint256 version;\\n }\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param registryName name for the registry\\n * @param registryAddress address of the new registry\\n */\\n function addRegistry(bytes32 registryName, address registryAddress)\\n external\\n payable;\\n\\n /**\\n * @notice Resolves a name to the latest registry address. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToLatestAddress(bytes32 name)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name and version to an address. Reverts if there is no registry with given name and version.\\n * @param name address of the registry you want to resolve to\\n * @param version version of the registry you want to resolve to\\n */\\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\\n external\\n view\\n returns (address);\\n\\n /**\\n * @notice Resolves a name to an array of all addresses. Reverts if no match is found.\\n * @param name name for the registry\\n * @return address address of the latest registry with the matching name\\n */\\n function resolveNameToAllAddresses(bytes32 name)\\n external\\n view\\n returns (address[] memory);\\n\\n /**\\n * @notice Resolves an address to registry entry data.\\n * @param registryAddress address of a registry you want to resolve\\n * @return name name of the resolved registry\\n * @return version version of the resolved registry\\n * @return isLatest boolean flag of whether the given address is the latest version of the given registries with\\n * matching name\\n */\\n function resolveAddressToRegistryData(address registryAddress)\\n external\\n view\\n returns (\\n bytes32 name,\\n uint256 version,\\n bool isLatest\\n );\\n}\\n\",\"keccak256\":\"0x0e403d7e259003f3826b3009ae3e39344706d7af8a0a5bd48ba45a6ca978226b\",\"license\":\"MIT\"},\"contracts/interfaces/ISwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlist.sol\\\";\\n\\ninterface ISwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlist);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xcd26195c5e3824e7984750a05c9fcb6dde3e266022c3bd1a9dcdda9e967a6f4c\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"../Swap.sol\\\";\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\nimport \\\"./PermissionlessSwapUtils.sol\\\";\\nimport \\\"./ShareProtocolFee.sol\\\";\\n\\n/**\\n * @title Swap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs. Part of this fee is given to the creator of the pool as an Admin fee,\\n * the amount of which is set when the pool is created. Saddle will collect to 50% of these Admin fees.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * @dev Most of the logic is stored as a library `PermissionlessSwapUtils` for the sake of reducing\\n * contract's deployment size.\\n */\\ncontract PermissionlessSwap is Swap, ShareProtocolFee {\\n using PermissionlessSwapUtils for SwapUtils.Swap;\\n\\n /**\\n * @notice Constructor for the PermissionlessSwap contract.\\n * @param _masterRegistry address of the MasterRegistry contract\\n */\\n constructor(IMasterRegistry _masterRegistry)\\n public\\n ShareProtocolFee(_masterRegistry)\\n {}\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n /**\\n * @notice Updates cached address of the fee collector\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual override initializer {\\n Swap.initialize(\\n _pooledTokens,\\n decimals,\\n lpTokenName,\\n lpTokenSymbol,\\n _a,\\n _fee,\\n _adminFee,\\n lpTokenTargetAddress\\n );\\n _updateFeeCollectorCache(MASTER_REGISTRY);\\n }\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner and the fee collector.\\n */\\n function withdrawAdminFees()\\n external\\n payable\\n virtual\\n override(Swap, ShareProtocolFee)\\n {\\n require(\\n msg.sender == owner() || msg.sender == feeCollector,\\n \\\"Caller is not authorized\\\"\\n );\\n PermissionlessSwapUtils.withdrawAdminFees(\\n swapStorage,\\n owner(),\\n feeCollector\\n );\\n }\\n}\\n\",\"keccak256\":\"0x36bb4e9bb6cfea001cb6d44018f5297c0552dddd1958e06232b529e4fe6deb58\",\"license\":\"MIT\"},\"contracts/permissionless/PermissionlessSwapUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"../SwapUtils.sol\\\";\\n\\n/**\\n * @title PermissionlessSwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary PermissionlessSwapUtils {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n /**\\n * @notice Withdraw all admin fees to two addresses evenly\\n * @param self Swap struct to withdraw fees from\\n * @param creator Address to send hald of the fees to. For the creator of the community pool.\\n * @param protocol Address to send the half of the fees to. For the protocol fee collection.\\n */\\n function withdrawAdminFees(\\n SwapUtils.Swap storage self,\\n address creator,\\n address protocol\\n ) internal {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)).sub(\\n self.balances[i]\\n ) / 2;\\n if (balance != 0) {\\n token.safeTransfer(creator, balance);\\n token.safeTransfer(protocol, balance);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x1b94e14de31e95f82bf8f47aa65f4c68c7152823cac6daf2b50c3923f20f2ecc\",\"license\":\"MIT\"},\"contracts/permissionless/ShareProtocolFee.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\nimport \\\"../interfaces/IMasterRegistry.sol\\\";\\n\\nabstract contract ShareProtocolFee {\\n IMasterRegistry public immutable MASTER_REGISTRY;\\n bytes32 public constant FEE_COLLECTOR_NAME =\\n 0x466565436f6c6c6563746f720000000000000000000000000000000000000000;\\n address public feeCollector;\\n\\n constructor(IMasterRegistry _masterRegistry) public {\\n MASTER_REGISTRY = _masterRegistry;\\n _updateFeeCollectorCache(_masterRegistry);\\n }\\n\\n /**\\n * @notice Updates cached address of the fee collector\\n */\\n function updateFeeCollectorCache() public payable virtual {\\n _updateFeeCollectorCache(MASTER_REGISTRY);\\n }\\n\\n function _updateFeeCollectorCache(IMasterRegistry masterRegistry)\\n internal\\n virtual\\n {\\n address _feeCollector = masterRegistry.resolveNameToLatestAddress(\\n FEE_COLLECTOR_NAME\\n );\\n require(_feeCollector != address(0), \\\"Fee collector cannot be empty\\\");\\n feeCollector = _feeCollector;\\n }\\n\\n /**\\n * @notice Withdraws admin fees to appropriate addresses\\n */\\n function withdrawAdminFees() external payable virtual;\\n}\\n\",\"keccak256\":\"0x4af76c8dd2356c160c60f1378a11a832f0e99e9bbb36908b95d3743f3aecbc32\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162003c0c38038062003c0c833981810160405260208110156200003757600080fd5b50516001600160601b0319606082901b166080528062000057816200005f565b505062000167565b6000816001600160a01b0316633705f6256b2332b2a1b7b63632b1ba37b960a11b60001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015620000b857600080fd5b505afa158015620000cd573d6000803e3d6000fd5b505050506040513d6020811015620000e457600080fd5b505190506001600160a01b03811662000144576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d480546001600160a01b0319166001600160a01b039290921691909117905550565b60805160601c613a7d6200018f60003980610baf5280611d135280611dd75250613a7d6000f3fe6080604052600436106101fe5760003560e01c806384cdd9bc1161011d578063b28cb6dc116100b0578063e25aa5fa1161007f578063ef0a712f11610064578063ef0a712f146109fc578063f2fad2b614610a26578063f2fde38b14610a50576101fe565b8063e25aa5fa14610968578063e6ab28061461097d576101fe565b8063b28cb6dc146106e6578063c415b95c14610936578063c4db7fa01461094b578063d46300fd14610953576101fe565b806391ceb3eb116100ec57806391ceb3eb14610652578063a43443901461067f578063a95b089f14610694578063ac841ed9146106d1576101fe565b806384cdd9bc1461056e5780638beb60b6146105e45780638da5cb5b146106015780639169558614610616576101fe565b80634d49e87d1161019557806366c0bd241161016457806366c0bd24146104b2578063715018a6146104fb57806382b86600146105105780638456cb5914610559576101fe565b80634d49e87d1461039a578063593d132c146104105780635c975abb146104335780635fd65f0f1461045c576101fe565b8063342a87a1116101d1578063342a87a11461030357806334e19907146103365780633e3a1560146103535780633f4ba83a14610385576101fe565b80630419b45a146102035780630ba819591461020d5780632472374d1461023457806331cd52b01461023c575b600080fd5b61020b610a83565b005b34801561021957600080fd5b50610222610b25565b60408051918252519081900360200190f35b61020b610baa565b6102b36004803603606081101561025257600080fd5b8135919081019060408101602082013564010000000081111561027457600080fd5b82018360208201111561028657600080fd5b803590602001918460208302840111640100000000831117156102a857600080fd5b919350915035610bd3565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102ef5781810151838201526020016102d7565b505050509050019250505060405180910390f35b34801561030f57600080fd5b506102226004803603604081101561032657600080fd5b508035906020013560ff16610e10565b61020b6004803603602081101561034c57600080fd5b5035610ec4565b6102226004803603608081101561036957600080fd5b5080359060ff6020820135169060408101359060600135610fc5565b34801561039157600080fd5b5061020b611191565b610222600480360360608110156103b057600080fd5b8101906020810181356401000000008111156103cb57600080fd5b8201836020820111156103dd57600080fd5b803590602001918460208302840111640100000000831117156103ff57600080fd5b91935091508035906020013561120d565b61020b6004803603604081101561042657600080fd5b50803590602001356113ad565b34801561043f57600080fd5b506104486114b6565b604080519115158252519081900360200190f35b34801561046857600080fd5b506104716114bf565b604080519788526020880196909652868601949094526060860192909252608085015260a08401526001600160a01b031660c0830152519081900360e00190f35b3480156104be57600080fd5b506104e5600480360360208110156104d557600080fd5b50356001600160a01b03166114e0565b6040805160ff9092168252519081900360200190f35b34801561050757600080fd5b5061020b61156d565b34801561051c57600080fd5b5061053d6004803603602081101561053357600080fd5b503560ff16611643565b604080516001600160a01b039092168252519081900360200190f35b34801561056557600080fd5b5061020b6116cb565b6102226004803603606081101561058457600080fd5b81019060208101813564010000000081111561059f57600080fd5b8201836020820111156105b157600080fd5b803590602001918460208302840111640100000000831117156105d357600080fd5b919350915080359060200135611747565b61020b600480360360208110156105fa57600080fd5b50356118e7565b34801561060d57600080fd5b5061053d6119cd565b610222600480360360a081101561062c57600080fd5b5060ff8135811691602081013590911690604081013590606081013590608001356119dc565b34801561065e57600080fd5b506102226004803603602081101561067557600080fd5b503560ff16611bb1565b34801561068b57600080fd5b50610222611c30565b3480156106a057600080fd5b50610222600480360360608110156106b757600080fd5b5060ff813581169160208101359091169060400135611c54565b3480156106dd57600080fd5b5061053d611d11565b61020b60048036036101008110156106fd57600080fd5b81019060208101813564010000000081111561071857600080fd5b82018360208201111561072a57600080fd5b8035906020019184602083028401116401000000008311171561074c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561079c57600080fd5b8201836020820111156107ae57600080fd5b803590602001918460208302840111640100000000831117156107d057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561082057600080fd5b82018360208201111561083257600080fd5b8035906020019184600183028401116401000000008311171561085457600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092959493602081019350359150506401000000008111156108a757600080fd5b8201836020820111156108b957600080fd5b803590602001918460018302840111640100000000831117156108db57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050823593505050602081013590604081013590606001356001600160a01b0316611d35565b34801561094257600080fd5b5061053d611e18565b61020b611e27565b34801561095f57600080fd5b50610222611f20565b34801561097457600080fd5b50610222611f74565b34801561098957600080fd5b50610222600480360360408110156109a057600080fd5b8101906020810181356401000000008111156109bb57600080fd5b8201836020820111156109cd57600080fd5b803590602001918460208302840111640100000000831117156109ef57600080fd5b9193509150351515611fc8565b348015610a0857600080fd5b5061022260048036036020811015610a1f57600080fd5b503561205d565b348015610a3257600080fd5b506102b360048036036020811015610a4957600080fd5b50356120eb565b348015610a5c57600080fd5b5061020b60048036036020811015610a7357600080fd5b50356001600160a01b0316612235565b610a8b6119cd565b6001600160a01b0316336001600160a01b03161480610ab4575060d4546001600160a01b031633145b610b05576040805162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f7420617574686f72697a65640000000000000000604482015290519081900360640190fd5b610b2360c9610b126119cd565b60d4546001600160a01b0316612362565b565b600060c973FdA5D2ad8b6d3884AbB799DA66f57175E870694163c9b64dcb90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b505af4158015610b8d573d6000803e3d6000fd5b505050506040513d6020811015610ba357600080fd5b5051905090565b610b237f00000000000000000000000000000000000000000000000000000000000000006124c9565b606060026097541415610c2d576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097558142811015610c88576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c9734a5208f83a17e030a18830521e4064e80728c4fc6373fd6b3e90918888886040518563ffffffff1660e01b815260040180858152602001848152602001806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060006040518083038186803b158015610d1957600080fd5b505af4158015610d2d573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526020811015610d7457600080fd5b8101908080516040519392919084640100000000821115610d9457600080fd5b908301906020820185811115610da957600080fd5b8251866020820283011164010000000082111715610dc657600080fd5b82525081516020918201928201910280838360005b83811015610df3578181015183820152602001610ddb565b505050509050016040525050509150506001609755949350505050565b604080517fe069274200000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260ff831660448201529051600091734a5208f83a17e030a18830521e4064e80728c4fc9163e069274291606480820192602092909190829003018186803b158015610e8f57600080fd5b505af4158015610ea3573d6000803e3d6000fd5b505050506040513d6020811015610eb957600080fd5b505190505b92915050565b610ecc6125f6565b6001600160a01b0316610edd6119cd565b6001600160a01b031614610f38576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f467e186c00000000000000000000000000000000000000000000000000000000815260c96004820152602481018390529051734a5208f83a17e030a18830521e4064e80728c4fc9163467e186c916044808301926000929190829003018186803b158015610faa57600080fd5b505af4158015610fbe573d6000803e3d6000fd5b5050505050565b60006002609754141561101f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561102c6114b6565b1561107e576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b81804211156110d4576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fe7a4db8100000000000000000000000000000000000000000000000000000000815260c960048201526024810188905260ff87166044820152606481018690529051734a5208f83a17e030a18830521e4064e80728c4fc9163e7a4db81916084808301926020929190829003018186803b15801561115657600080fd5b505af415801561116a573d6000803e3d6000fd5b505050506040513d602081101561118057600080fd5b505160016097559695505050505050565b6111996125f6565b6001600160a01b03166111aa6119cd565b6001600160a01b031614611205576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610b236125fa565b600060026097541415611267576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556112746114b6565b156112c6576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b818042111561131c576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c9734a5208f83a17e030a18830521e4064e80728c4fc6340370edf90918888886040518563ffffffff1660e01b815260040180858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b15801561115657600080fd5b6113b56125f6565b6001600160a01b03166113c66119cd565b6001600160a01b031614611421576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f58fdd79b00000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260448101839052905173FdA5D2ad8b6d3884AbB799DA66f57175E8706941916358fdd79b916064808301926000929190829003018186803b15801561149a57600080fd5b505af41580156114ae573d6000803e3d6000fd5b505050505050565b60655460ff1690565b60c95460ca5460cb5460cc5460cd5460ce5460cf546001600160a01b031687565b6001600160a01b038116600081815260d36020526040812054909160ff9091169061150a82611643565b6001600160a01b031614611565576040805162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f74206578697374000000000000000000000000604482015290519081900360640190fd5b90505b919050565b6115756125f6565b6001600160a01b03166115866119cd565b6001600160a01b0316146115e1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60d05460009060ff83161061169f576040805162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e67650000000000000000000000000000000000000000604482015290519081900360640190fd5b60d0805460ff84169081106116b057fe5b6000918252602090912001546001600160a01b031692915050565b6116d36125f6565b6001600160a01b03166116e46119cd565b6001600160a01b03161461173f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610b236126a3565b6000600260975414156117a1576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556117ae6114b6565b15611800576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611856576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c9734a5208f83a17e030a18830521e4064e80728c4fc6341b91c2690918888886040518563ffffffff1660e01b815260040180858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b15801561115657600080fd5b6118ef6125f6565b6001600160a01b03166119006119cd565b6001600160a01b03161461195b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f7046727600000000000000000000000000000000000000000000000000000000815260c96004820152602481018390529051734a5208f83a17e030a18830521e4064e80728c4fc916370467276916044808301926000929190829003018186803b158015610faa57600080fd5b6033546001600160a01b031690565b600060026097541415611a36576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611a436114b6565b15611a95576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611aeb576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fa5397b2200000000000000000000000000000000000000000000000000000000815260c9600482015260ff808a1660248301528816604482015260648101879052608481018690529051734a5208f83a17e030a18830521e4064e80728c4fc9163a5397b229160a4808301926020929190829003018186803b158015611b7557600080fd5b505af4158015611b89573d6000803e3d6000fd5b505050506040513d6020811015611b9f57600080fd5b50516001609755979650505050505050565b60d05460009060ff831610611c0d576040805162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e67650000000000000000000000000000604482015290519081900360640190fd5b60d2805460ff8416908110611c1e57fe5b90600052602060002001549050919050565b7f466565436f6c6c6563746f72000000000000000000000000000000000000000081565b604080517f4b23603c00000000000000000000000000000000000000000000000000000000815260c9600482015260ff808616602483015284166044820152606481018390529051600091734a5208f83a17e030a18830521e4064e80728c4fc91634b23603c91608480820192602092909190829003018186803b158015611cdb57600080fd5b505af4158015611cef573d6000803e3d6000fd5b505050506040513d6020811015611d0557600080fd5b505190505b9392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600054610100900460ff1680611d4e5750611d4e612733565b80611d5c575060005460ff16155b611d975760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015611dc2576000805460ff1961ff0019909116610100171660011790555b611dd28989898989898989612744565b611dfb7f00000000000000000000000000000000000000000000000000000000000000006124c9565b8015611e0d576000805461ff00191690555b505050505050505050565b60d4546001600160a01b031681565b611e2f6125f6565b6001600160a01b0316611e406119cd565b6001600160a01b031614611e9b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517ff14e211e00000000000000000000000000000000000000000000000000000000815260c96004820152905173FdA5D2ad8b6d3884AbB799DA66f57175E87069419163f14e211e916024808301926000929190829003018186803b158015611f0657600080fd5b505af4158015611f1a573d6000803e3d6000fd5b50505050565b600060c973FdA5D2ad8b6d3884AbB799DA66f57175E870694163b0a14cfc90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b600060c9734a5208f83a17e030a18830521e4064e80728c4fc6371906c2c90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b600060c9734a5208f83a17e030a18830521e4064e80728c4fc63834b491090918686866040518563ffffffff1660e01b8152600401808581526020018060200183151581526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b158015611cdb57600080fd5b600060c9734a5208f83a17e030a18830521e4064e80728c4fc637d0481609091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156120b957600080fd5b505af41580156120cd573d6000803e3d6000fd5b505050506040513d60208110156120e357600080fd5b505192915050565b606060c9734a5208f83a17e030a18830521e4064e80728c4fc6370703e4a9091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561214757600080fd5b505af415801561215b573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405260208110156121a257600080fd5b81019080805160405193929190846401000000008211156121c257600080fd5b9083019060208201858111156121d757600080fd5b82518660208202830111640100000000821117156121f457600080fd5b82525081516020918201928201910280838360005b83811015612221578181015183820152602001612209565b505050509050016040525050509050919050565b61223d6125f6565b6001600160a01b031661224e6119cd565b6001600160a01b0316146122a9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166122ee5760405162461bcd60e51b81526004018080602001828103825260268152602001806139836026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060836007018054806020026020016040519081016040528092919081815260200182805480156123bc57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161239e575b5050505050905060005b8151811015610fbe5760008282815181106123dd57fe5b60200260200101519050600060026124878860090185815481106123fd57fe5b9060005260206000200154846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d602081101561247f57600080fd5b505190612f3f565b8161248e57fe5b04905080156124bf576124ab6001600160a01b0383168783612f9c565b6124bf6001600160a01b0383168683612f9c565b50506001016123c6565b6000816001600160a01b0316633705f6257f466565436f6c6c6563746f72000000000000000000000000000000000000000060001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561253257600080fd5b505afa158015612546573d6000803e3d6000fd5b505050506040513d602081101561255c57600080fd5b505190506001600160a01b0381166125bb576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b3390565b6126026114b6565b612653576040805162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6126866125f6565b604080516001600160a01b039092168252519081900360200190a1565b6126ab6114b6565b156126fd576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126866125f6565b600061273e30613021565b15905090565b600054610100900460ff168061275d575061275d612733565b8061276b575060005460ff16155b6127a65760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156127d1576000805460ff1961ff0019909116610100171660011790555b6127d9613027565b6127e16130e1565b6001895111612837576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d203100000000000000604482015290519081900360640190fd5b60208951111561288e576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e20333200000000000000604482015290519081900360640190fd5b87518951146128e4576040805162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d6174636800604482015290519081900360640190fd5b6060885167ffffffffffffffff811180156128fe57600080fd5b50604051908082528060200260200182016040528015612928578160200160208202803683370190505b50905060005b8a518160ff161015612ba65760ff811615612a175760d360008c8360ff168151811061295657fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff161580156129c657508a8160ff168151811061299457fe5b60200260200101516001600160a01b03168b6000815181106129b257fe5b60200260200101516001600160a01b031614155b612a17576040805162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e7300000000000000000000000000000000604482015290519081900360640190fd5b60006001600160a01b03168b8260ff1681518110612a3157fe5b60200260200101516001600160a01b03161415612a95576040805162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d3230000000604482015290519081900360640190fd5b601260ff168a8260ff1681518110612aa957fe5b602002602001015160ff161115612b07576040805162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d6178000000000000604482015290519081900360640190fd5b612b378a8260ff1681518110612b1957fe5b602002602001015160ff16601260ff16612f3f90919063ffffffff16565b600a0a828260ff1681518110612b4957fe5b6020026020010181815250508060d360008d8460ff1681518110612b6957fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191660ff9290921691909117905560010161292e565b50620f42408610612bfe576040805162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d0000000000000000000000000000604482015290519081900360640190fd5b6305f5e1008510612c56576040805162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d000000000000000000000000604482015290519081900360640190fd5b6402540be4008410612caf576040805162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d00000000000000604482015290519081900360640190fd5b6000612cba84613176565b9050806001600160a01b0316634cd88b768a8a6040518363ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019080838360005b83811015612d1d578181015183820152602001612d05565b50505050905090810190601f168015612d4a5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b83811015612d7d578181015183820152602001612d65565b50505050905090810190601f168015612daa5780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b158015612dcb57600080fd5b505af1158015612ddf573d6000803e3d6000fd5b505050506040513d6020811015612df557600080fd5b5051612e48576040805162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e6500000000604482015290519081900360640190fd5b60cf80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790558a51612e8e9060d09060208e0190613872565b508151612ea29060d19060208501906138ef565b508a5167ffffffffffffffff81118015612ebb57600080fd5b50604051908082528060200260200182016040528015612ee5578160200160208202803683370190505b508051612efa9160d2916020909101906138ef565b50612f06876064613231565b60c955612f14876064613231565b60ca55505060cd84905560ce8390558015611e0d576000805461ff0019169055505050505050505050565b600082821115612f96576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261301c90849061328a565b505050565b3b151590565b600054610100900460ff16806130405750613040612733565b8061304e575060005460ff16155b6130895760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156130b4576000805460ff1961ff0019909116610100171660011790555b6130bc61333b565b6130c46133db565b6130cc6134ec565b80156130de576000805461ff00191690555b50565b600054610100900460ff16806130fa57506130fa612733565b80613108575060005460ff16155b6131435760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff1615801561316e576000805460ff1961ff0019909116610100171660011790555b6130cc613597565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116611568576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b60008261324057506000610ebe565b8282028284828161324d57fe5b0414611d0a5760405162461bcd60e51b81526004018080602001828103825260218152602001806139fd6021913960400191505060405180910390fd5b60606132df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661363d9092919063ffffffff16565b80519091501561301c578080602001905160208110156132fe57600080fd5b505161301c5760405162461bcd60e51b815260040180806020018281038252602a815260200180613a1e602a913960400191505060405180910390fd5b600054610100900460ff16806133545750613354612733565b80613362575060005460ff16155b61339d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156130cc576000805460ff1961ff00199091166101001716600117905580156130de576000805461ff001916905550565b600054610100900460ff16806133f457506133f4612733565b80613402575060005460ff16155b61343d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613468576000805460ff1961ff0019909116610100171660011790555b60006134726125f6565b603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156130de576000805461ff001916905550565b600054610100900460ff16806135055750613505612733565b80613513575060005460ff16155b61354e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613579576000805460ff1961ff0019909116610100171660011790555b6065805460ff1916905580156130de576000805461ff001916905550565b600054610100900460ff16806135b057506135b0612733565b806135be575060005460ff16155b6135f95760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613624576000805460ff1961ff0019909116610100171660011790555b600160975580156130de576000805461ff001916905550565b606061364c8484600085613654565b949350505050565b6060824710156136955760405162461bcd60e51b81526004018080602001828103825260268152602001806139a96026913960400191505060405180910390fd5b61369e85613021565b6136ef576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061374c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161370f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146137ae576040519150601f19603f3d011682016040523d82523d6000602084013e6137b3565b606091505b50915091506137c38282866137ce565b979650505050505050565b606083156137dd575081611d0a565b8251156137ed5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561383757818101518382015260200161381f565b50505050905090810190601f1680156138645780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8280548282559060005260206000209081019282156138df579160200282015b828111156138df57825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613892565b506138eb929150613936565b5090565b82805482825590600052602060002090810192821561392a579160200282015b8281111561392a57825182559160200191906001019061390f565b506138eb92915061396d565b5b808211156138eb5780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101613937565b5b808211156138eb576000815560010161396e56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212206765335d9020510e073158c490531fc068b88a389f5a3a37b595685397d6ec3664736f6c634300060c0033", + "deployedBytecode": "0x6080604052600436106101fe5760003560e01c806384cdd9bc1161011d578063b28cb6dc116100b0578063e25aa5fa1161007f578063ef0a712f11610064578063ef0a712f146109fc578063f2fad2b614610a26578063f2fde38b14610a50576101fe565b8063e25aa5fa14610968578063e6ab28061461097d576101fe565b8063b28cb6dc146106e6578063c415b95c14610936578063c4db7fa01461094b578063d46300fd14610953576101fe565b806391ceb3eb116100ec57806391ceb3eb14610652578063a43443901461067f578063a95b089f14610694578063ac841ed9146106d1576101fe565b806384cdd9bc1461056e5780638beb60b6146105e45780638da5cb5b146106015780639169558614610616576101fe565b80634d49e87d1161019557806366c0bd241161016457806366c0bd24146104b2578063715018a6146104fb57806382b86600146105105780638456cb5914610559576101fe565b80634d49e87d1461039a578063593d132c146104105780635c975abb146104335780635fd65f0f1461045c576101fe565b8063342a87a1116101d1578063342a87a11461030357806334e19907146103365780633e3a1560146103535780633f4ba83a14610385576101fe565b80630419b45a146102035780630ba819591461020d5780632472374d1461023457806331cd52b01461023c575b600080fd5b61020b610a83565b005b34801561021957600080fd5b50610222610b25565b60408051918252519081900360200190f35b61020b610baa565b6102b36004803603606081101561025257600080fd5b8135919081019060408101602082013564010000000081111561027457600080fd5b82018360208201111561028657600080fd5b803590602001918460208302840111640100000000831117156102a857600080fd5b919350915035610bd3565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102ef5781810151838201526020016102d7565b505050509050019250505060405180910390f35b34801561030f57600080fd5b506102226004803603604081101561032657600080fd5b508035906020013560ff16610e10565b61020b6004803603602081101561034c57600080fd5b5035610ec4565b6102226004803603608081101561036957600080fd5b5080359060ff6020820135169060408101359060600135610fc5565b34801561039157600080fd5b5061020b611191565b610222600480360360608110156103b057600080fd5b8101906020810181356401000000008111156103cb57600080fd5b8201836020820111156103dd57600080fd5b803590602001918460208302840111640100000000831117156103ff57600080fd5b91935091508035906020013561120d565b61020b6004803603604081101561042657600080fd5b50803590602001356113ad565b34801561043f57600080fd5b506104486114b6565b604080519115158252519081900360200190f35b34801561046857600080fd5b506104716114bf565b604080519788526020880196909652868601949094526060860192909252608085015260a08401526001600160a01b031660c0830152519081900360e00190f35b3480156104be57600080fd5b506104e5600480360360208110156104d557600080fd5b50356001600160a01b03166114e0565b6040805160ff9092168252519081900360200190f35b34801561050757600080fd5b5061020b61156d565b34801561051c57600080fd5b5061053d6004803603602081101561053357600080fd5b503560ff16611643565b604080516001600160a01b039092168252519081900360200190f35b34801561056557600080fd5b5061020b6116cb565b6102226004803603606081101561058457600080fd5b81019060208101813564010000000081111561059f57600080fd5b8201836020820111156105b157600080fd5b803590602001918460208302840111640100000000831117156105d357600080fd5b919350915080359060200135611747565b61020b600480360360208110156105fa57600080fd5b50356118e7565b34801561060d57600080fd5b5061053d6119cd565b610222600480360360a081101561062c57600080fd5b5060ff8135811691602081013590911690604081013590606081013590608001356119dc565b34801561065e57600080fd5b506102226004803603602081101561067557600080fd5b503560ff16611bb1565b34801561068b57600080fd5b50610222611c30565b3480156106a057600080fd5b50610222600480360360608110156106b757600080fd5b5060ff813581169160208101359091169060400135611c54565b3480156106dd57600080fd5b5061053d611d11565b61020b60048036036101008110156106fd57600080fd5b81019060208101813564010000000081111561071857600080fd5b82018360208201111561072a57600080fd5b8035906020019184602083028401116401000000008311171561074c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561079c57600080fd5b8201836020820111156107ae57600080fd5b803590602001918460208302840111640100000000831117156107d057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929594936020810193503591505064010000000081111561082057600080fd5b82018360208201111561083257600080fd5b8035906020019184600183028401116401000000008311171561085457600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092959493602081019350359150506401000000008111156108a757600080fd5b8201836020820111156108b957600080fd5b803590602001918460018302840111640100000000831117156108db57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955050823593505050602081013590604081013590606001356001600160a01b0316611d35565b34801561094257600080fd5b5061053d611e18565b61020b611e27565b34801561095f57600080fd5b50610222611f20565b34801561097457600080fd5b50610222611f74565b34801561098957600080fd5b50610222600480360360408110156109a057600080fd5b8101906020810181356401000000008111156109bb57600080fd5b8201836020820111156109cd57600080fd5b803590602001918460208302840111640100000000831117156109ef57600080fd5b9193509150351515611fc8565b348015610a0857600080fd5b5061022260048036036020811015610a1f57600080fd5b503561205d565b348015610a3257600080fd5b506102b360048036036020811015610a4957600080fd5b50356120eb565b348015610a5c57600080fd5b5061020b60048036036020811015610a7357600080fd5b50356001600160a01b0316612235565b610a8b6119cd565b6001600160a01b0316336001600160a01b03161480610ab4575060d4546001600160a01b031633145b610b05576040805162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f7420617574686f72697a65640000000000000000604482015290519081900360640190fd5b610b2360c9610b126119cd565b60d4546001600160a01b0316612362565b565b600060c973__$a50a14a4f4d416df093fe8223c9bbe01e7$__63c9b64dcb90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b505af4158015610b8d573d6000803e3d6000fd5b505050506040513d6020811015610ba357600080fd5b5051905090565b610b237f00000000000000000000000000000000000000000000000000000000000000006124c9565b606060026097541415610c2d576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097558142811015610c88576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6373fd6b3e90918888886040518563ffffffff1660e01b815260040180858152602001848152602001806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060006040518083038186803b158015610d1957600080fd5b505af4158015610d2d573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526020811015610d7457600080fd5b8101908080516040519392919084640100000000821115610d9457600080fd5b908301906020820185811115610da957600080fd5b8251866020820283011164010000000082111715610dc657600080fd5b82525081516020918201928201910280838360005b83811015610df3578181015183820152602001610ddb565b505050509050016040525050509150506001609755949350505050565b604080517fe069274200000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260ff83166044820152905160009173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__9163e069274291606480820192602092909190829003018186803b158015610e8f57600080fd5b505af4158015610ea3573d6000803e3d6000fd5b505050506040513d6020811015610eb957600080fd5b505190505b92915050565b610ecc6125f6565b6001600160a01b0316610edd6119cd565b6001600160a01b031614610f38576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f467e186c00000000000000000000000000000000000000000000000000000000815260c9600482015260248101839052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__9163467e186c916044808301926000929190829003018186803b158015610faa57600080fd5b505af4158015610fbe573d6000803e3d6000fd5b5050505050565b60006002609754141561101f576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260975561102c6114b6565b1561107e576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b81804211156110d4576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fe7a4db8100000000000000000000000000000000000000000000000000000000815260c960048201526024810188905260ff8716604482015260648101869052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__9163e7a4db81916084808301926020929190829003018186803b15801561115657600080fd5b505af415801561116a573d6000803e3d6000fd5b505050506040513d602081101561118057600080fd5b505160016097559695505050505050565b6111996125f6565b6001600160a01b03166111aa6119cd565b6001600160a01b031614611205576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610b236125fa565b600060026097541415611267576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556112746114b6565b156112c6576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b818042111561131c576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6340370edf90918888886040518563ffffffff1660e01b815260040180858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b15801561115657600080fd5b6113b56125f6565b6001600160a01b03166113c66119cd565b6001600160a01b031614611421576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f58fdd79b00000000000000000000000000000000000000000000000000000000815260c960048201526024810184905260448101839052905173__$a50a14a4f4d416df093fe8223c9bbe01e7$__916358fdd79b916064808301926000929190829003018186803b15801561149a57600080fd5b505af41580156114ae573d6000803e3d6000fd5b505050505050565b60655460ff1690565b60c95460ca5460cb5460cc5460cd5460ce5460cf546001600160a01b031687565b6001600160a01b038116600081815260d36020526040812054909160ff9091169061150a82611643565b6001600160a01b031614611565576040805162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f74206578697374000000000000000000000000604482015290519081900360640190fd5b90505b919050565b6115756125f6565b6001600160a01b03166115866119cd565b6001600160a01b0316146115e1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60d05460009060ff83161061169f576040805162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e67650000000000000000000000000000000000000000604482015290519081900360640190fd5b60d0805460ff84169081106116b057fe5b6000918252602090912001546001600160a01b031692915050565b6116d36125f6565b6001600160a01b03166116e46119cd565b6001600160a01b03161461173f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610b236126a3565b6000600260975414156117a1576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026097556117ae6114b6565b15611800576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611856576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b60c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6341b91c2690918888886040518563ffffffff1660e01b815260040180858152602001806020018381526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b15801561115657600080fd5b6118ef6125f6565b6001600160a01b03166119006119cd565b6001600160a01b03161461195b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517f7046727600000000000000000000000000000000000000000000000000000000815260c9600482015260248101839052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__916370467276916044808301926000929190829003018186803b158015610faa57600080fd5b6033546001600160a01b031690565b600060026097541415611a36576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002609755611a436114b6565b15611a95576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b8180421115611aeb576040805162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d657400000000000000000000000000000000604482015290519081900360640190fd5b604080517fa5397b2200000000000000000000000000000000000000000000000000000000815260c9600482015260ff808a166024830152881660448201526064810187905260848101869052905173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__9163a5397b229160a4808301926020929190829003018186803b158015611b7557600080fd5b505af4158015611b89573d6000803e3d6000fd5b505050506040513d6020811015611b9f57600080fd5b50516001609755979650505050505050565b60d05460009060ff831610611c0d576040805162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e67650000000000000000000000000000604482015290519081900360640190fd5b60d2805460ff8416908110611c1e57fe5b90600052602060002001549050919050565b7f466565436f6c6c6563746f72000000000000000000000000000000000000000081565b604080517f4b23603c00000000000000000000000000000000000000000000000000000000815260c9600482015260ff80861660248301528416604482015260648101839052905160009173__$a4e4384d4f8ec13c7a898ae597a4175ef6$__91634b23603c91608480820192602092909190829003018186803b158015611cdb57600080fd5b505af4158015611cef573d6000803e3d6000fd5b505050506040513d6020811015611d0557600080fd5b505190505b9392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600054610100900460ff1680611d4e5750611d4e612733565b80611d5c575060005460ff16155b611d975760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015611dc2576000805460ff1961ff0019909116610100171660011790555b611dd28989898989898989612744565b611dfb7f00000000000000000000000000000000000000000000000000000000000000006124c9565b8015611e0d576000805461ff00191690555b505050505050505050565b60d4546001600160a01b031681565b611e2f6125f6565b6001600160a01b0316611e406119cd565b6001600160a01b031614611e9b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b604080517ff14e211e00000000000000000000000000000000000000000000000000000000815260c96004820152905173__$a50a14a4f4d416df093fe8223c9bbe01e7$__9163f14e211e916024808301926000929190829003018186803b158015611f0657600080fd5b505af4158015611f1a573d6000803e3d6000fd5b50505050565b600060c973__$a50a14a4f4d416df093fe8223c9bbe01e7$__63b0a14cfc90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b600060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6371906c2c90916040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610b7957600080fd5b600060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__63834b491090918686866040518563ffffffff1660e01b8152600401808581526020018060200183151581526020018281038252858582818152602001925060200280828437600081840152601f19601f8201169050808301925050509550505050505060206040518083038186803b158015611cdb57600080fd5b600060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__637d0481609091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156120b957600080fd5b505af41580156120cd573d6000803e3d6000fd5b505050506040513d60208110156120e357600080fd5b505192915050565b606060c973__$a4e4384d4f8ec13c7a898ae597a4175ef6$__6370703e4a9091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561214757600080fd5b505af415801561215b573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405260208110156121a257600080fd5b81019080805160405193929190846401000000008211156121c257600080fd5b9083019060208201858111156121d757600080fd5b82518660208202830111640100000000821117156121f457600080fd5b82525081516020918201928201910280838360005b83811015612221578181015183820152602001612209565b505050509050016040525050509050919050565b61223d6125f6565b6001600160a01b031661224e6119cd565b6001600160a01b0316146122a9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166122ee5760405162461bcd60e51b81526004018080602001828103825260268152602001806139836026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060836007018054806020026020016040519081016040528092919081815260200182805480156123bc57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161239e575b5050505050905060005b8151811015610fbe5760008282815181106123dd57fe5b60200260200101519050600060026124878860090185815481106123fd57fe5b9060005260206000200154846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561245557600080fd5b505afa158015612469573d6000803e3d6000fd5b505050506040513d602081101561247f57600080fd5b505190612f3f565b8161248e57fe5b04905080156124bf576124ab6001600160a01b0383168783612f9c565b6124bf6001600160a01b0383168683612f9c565b50506001016123c6565b6000816001600160a01b0316633705f6257f466565436f6c6c6563746f72000000000000000000000000000000000000000060001b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561253257600080fd5b505afa158015612546573d6000803e3d6000fd5b505050506040513d602081101561255c57600080fd5b505190506001600160a01b0381166125bb576040805162461bcd60e51b815260206004820152601d60248201527f46656520636f6c6c6563746f722063616e6e6f7420626520656d707479000000604482015290519081900360640190fd5b60d480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039290921691909117905550565b3390565b6126026114b6565b612653576040805162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015290519081900360640190fd5b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6126866125f6565b604080516001600160a01b039092168252519081900360200190a1565b6126ab6114b6565b156126fd576040805162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015290519081900360640190fd5b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126866125f6565b600061273e30613021565b15905090565b600054610100900460ff168061275d575061275d612733565b8061276b575060005460ff16155b6127a65760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156127d1576000805460ff1961ff0019909116610100171660011790555b6127d9613027565b6127e16130e1565b6001895111612837576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d203100000000000000604482015290519081900360640190fd5b60208951111561288e576040805162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e20333200000000000000604482015290519081900360640190fd5b87518951146128e4576040805162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d6174636800604482015290519081900360640190fd5b6060885167ffffffffffffffff811180156128fe57600080fd5b50604051908082528060200260200182016040528015612928578160200160208202803683370190505b50905060005b8a518160ff161015612ba65760ff811615612a175760d360008c8360ff168151811061295657fe5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff161580156129c657508a8160ff168151811061299457fe5b60200260200101516001600160a01b03168b6000815181106129b257fe5b60200260200101516001600160a01b031614155b612a17576040805162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e7300000000000000000000000000000000604482015290519081900360640190fd5b60006001600160a01b03168b8260ff1681518110612a3157fe5b60200260200101516001600160a01b03161415612a95576040805162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d3230000000604482015290519081900360640190fd5b601260ff168a8260ff1681518110612aa957fe5b602002602001015160ff161115612b07576040805162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d6178000000000000604482015290519081900360640190fd5b612b378a8260ff1681518110612b1957fe5b602002602001015160ff16601260ff16612f3f90919063ffffffff16565b600a0a828260ff1681518110612b4957fe5b6020026020010181815250508060d360008d8460ff1681518110612b6957fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191660ff9290921691909117905560010161292e565b50620f42408610612bfe576040805162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d0000000000000000000000000000604482015290519081900360640190fd5b6305f5e1008510612c56576040805162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d000000000000000000000000604482015290519081900360640190fd5b6402540be4008410612caf576040805162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d00000000000000604482015290519081900360640190fd5b6000612cba84613176565b9050806001600160a01b0316634cd88b768a8a6040518363ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019080838360005b83811015612d1d578181015183820152602001612d05565b50505050905090810190601f168015612d4a5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b83811015612d7d578181015183820152602001612d65565b50505050905090810190601f168015612daa5780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b158015612dcb57600080fd5b505af1158015612ddf573d6000803e3d6000fd5b505050506040513d6020811015612df557600080fd5b5051612e48576040805162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e6500000000604482015290519081900360640190fd5b60cf80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790558a51612e8e9060d09060208e0190613872565b508151612ea29060d19060208501906138ef565b508a5167ffffffffffffffff81118015612ebb57600080fd5b50604051908082528060200260200182016040528015612ee5578160200160208202803683370190505b508051612efa9160d2916020909101906138ef565b50612f06876064613231565b60c955612f14876064613231565b60ca55505060cd84905560ce8390558015611e0d576000805461ff0019169055505050505050505050565b600082821115612f96576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261301c90849061328a565b505050565b3b151590565b600054610100900460ff16806130405750613040612733565b8061304e575060005460ff16155b6130895760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156130b4576000805460ff1961ff0019909116610100171660011790555b6130bc61333b565b6130c46133db565b6130cc6134ec565b80156130de576000805461ff00191690555b50565b600054610100900460ff16806130fa57506130fa612733565b80613108575060005460ff16155b6131435760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff1615801561316e576000805460ff1961ff0019909116610100171660011790555b6130cc613597565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116611568576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b60008261324057506000610ebe565b8282028284828161324d57fe5b0414611d0a5760405162461bcd60e51b81526004018080602001828103825260218152602001806139fd6021913960400191505060405180910390fd5b60606132df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661363d9092919063ffffffff16565b80519091501561301c578080602001905160208110156132fe57600080fd5b505161301c5760405162461bcd60e51b815260040180806020018281038252602a815260200180613a1e602a913960400191505060405180910390fd5b600054610100900460ff16806133545750613354612733565b80613362575060005460ff16155b61339d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff161580156130cc576000805460ff1961ff00199091166101001716600117905580156130de576000805461ff001916905550565b600054610100900460ff16806133f457506133f4612733565b80613402575060005460ff16155b61343d5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613468576000805460ff1961ff0019909116610100171660011790555b60006134726125f6565b603380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156130de576000805461ff001916905550565b600054610100900460ff16806135055750613505612733565b80613513575060005460ff16155b61354e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613579576000805460ff1961ff0019909116610100171660011790555b6065805460ff1916905580156130de576000805461ff001916905550565b600054610100900460ff16806135b057506135b0612733565b806135be575060005460ff16155b6135f95760405162461bcd60e51b815260040180806020018281038252602e8152602001806139cf602e913960400191505060405180910390fd5b600054610100900460ff16158015613624576000805460ff1961ff0019909116610100171660011790555b600160975580156130de576000805461ff001916905550565b606061364c8484600085613654565b949350505050565b6060824710156136955760405162461bcd60e51b81526004018080602001828103825260268152602001806139a96026913960400191505060405180910390fd5b61369e85613021565b6136ef576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061374c57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161370f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146137ae576040519150601f19603f3d011682016040523d82523d6000602084013e6137b3565b606091505b50915091506137c38282866137ce565b979650505050505050565b606083156137dd575081611d0a565b8251156137ed5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561383757818101518382015260200161381f565b50505050905090810190601f1680156138645780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b8280548282559060005260206000209081019282156138df579160200282015b828111156138df57825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613892565b506138eb929150613936565b5090565b82805482825590600052602060002090810192821561392a579160200282015b8281111561392a57825182559160200191906001019061390f565b506138eb92915061396d565b5b808211156138eb5780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101613937565b5b808211156138eb576000815560010161396e56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212206765335d9020510e073158c490531fc068b88a389f5a3a37b595685397d6ec3664736f6c634300060c0033", + "libraries": { + "SwapUtils": "0x4a5208f83a17e030a18830521e4064e80728c4fc", + "AmplificationUtils": "0xFdA5D2ad8b6d3884AbB799DA66f57175E8706941" + }, + "devdoc": { + "details": "Most of the logic is stored as a library `PermissionlessSwapUtils` for the sake of reducing contract's deployment size.", + "kind": "dev", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "deadline": "latest timestamp to accept this transaction", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation" + }, + "returns": { + "_0": "amount of LP token user minted and received" + } + }, + "calculateRemoveLiquidity(uint256)": { + "params": { + "amount": "the amount of LP tokens that would be burned on withdrawal" + }, + "returns": { + "_0": "array of token balances that the user will receive" + } + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "params": { + "tokenAmount": "the amount of LP token to burn", + "tokenIndex": "index of which token will be withdrawn" + }, + "returns": { + "availableTokenAmount": "calculated amount of underlying token available to withdraw" + } + }, + "calculateSwap(uint8,uint8,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of tokens the user will receive" + } + }, + "calculateTokenAmount(uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal" + }, + "returns": { + "_0": "token amount the user will receive" + } + }, + "constructor": { + "params": { + "_masterRegistry": "address of the MasterRegistry contract" + } + }, + "getA()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter" + } + }, + "getAPrecise()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter in its raw precision form" + } + }, + "getAdminBalance(uint256)": { + "params": { + "index": "Index of the pooled token" + }, + "returns": { + "_0": "admin's token balance in the token's precision" + } + }, + "getToken(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "address of the token at given index" + } + }, + "getTokenBalance(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "current balance of the pooled token at given index with token's native precision" + } + }, + "getTokenIndex(address)": { + "params": { + "tokenAddress": "address of the token" + }, + "returns": { + "_0": "the index of the given token address" + } + }, + "getVirtualPrice()": { + "returns": { + "_0": "the virtual price, scaled to the POOL_PRECISION_DECIMALS" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "rampA(uint256,uint256)": { + "params": { + "futureA": "the new A to ramp towards", + "futureTime": "timestamp when the new A should be reached" + } + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "details": "Liquidity can always be removed, even when the pool is paused.", + "params": { + "amount": "the amount of LP tokens to burn", + "deadline": "latest timestamp to accept this transaction", + "minAmounts": "the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation" + }, + "returns": { + "_0": "amounts of tokens user received" + } + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "deadline": "latest timestamp to accept this transaction", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation." + }, + "returns": { + "_0": "amount of LP tokens burned" + } + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "minAmount": "the minimum amount to withdraw, otherwise revert", + "tokenAmount": "the amount of the token you want to receive", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount of chosen token user received" + } + }, + "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." + }, + "setAdminFee(uint256)": { + "params": { + "newAdminFee": "new admin fee to be applied on future transactions" + } + }, + "setSwapFee(uint256)": { + "params": { + "newSwapFee": "new swap fee to be applied on future transactions" + } + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "dx": "the amount of tokens the user wants to swap from", + "minDy": "the min amount the user would like to receive, or revert.", + "tokenIndexFrom": "the token the user wants to swap from", + "tokenIndexTo": "the token the user wants to swap to" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "Swap - A StableSwap implementation in solidity.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "notice": "Add liquidity to the pool with the given amounts of tokens" + }, + "calculateRemoveLiquidity(uint256)": { + "notice": "A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens" + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "notice": "Calculate the amount of underlying token available to withdraw when withdrawing via only single token" + }, + "calculateSwap(uint8,uint8,uint256)": { + "notice": "Calculate amount of tokens you receive on swap" + }, + "calculateTokenAmount(uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running" + }, + "constructor": "Constructor for the PermissionlessSwap contract.", + "getA()": { + "notice": "Return A, the amplification coefficient * n * (n - 1)" + }, + "getAPrecise()": { + "notice": "Return A in its raw precision form" + }, + "getAdminBalance(uint256)": { + "notice": "This function reads the accumulated amount of admin fees of the token with given index" + }, + "getToken(uint8)": { + "notice": "Return address of the pooled token at given index. Reverts if tokenIndex is out of range." + }, + "getTokenBalance(uint8)": { + "notice": "Return current balance of the pooled token at given index" + }, + "getTokenIndex(address)": { + "notice": "Return the index of the given token address. Reverts if no matching token is found." + }, + "getVirtualPrice()": { + "notice": "Get the virtual price, to help calculate profit" + }, + "initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)": { + "notice": "Updates cached address of the fee collector" + }, + "pause()": { + "notice": "Pause the contract. Revert if already paused." + }, + "rampA(uint256,uint256)": { + "notice": "Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range." + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "notice": "Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "notice": "Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "setAdminFee(uint256)": { + "notice": "Update the admin fee. Admin fee takes portion of the swap fee." + }, + "setSwapFee(uint256)": { + "notice": "Update the swap fee to be applied on swaps" + }, + "stopRampA()": { + "notice": "Stop ramping A immediately. Reverts if ramp A is already stopped." + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "notice": "Swap two tokens using this pool" + }, + "unpause()": { + "notice": "Unpause the contract. Revert if already unpaused." + }, + "updateFeeCollectorCache()": { + "notice": "Updates cached address of the fee collector" + }, + "withdrawAdminFees()": { + "notice": "Withdraw all admin fees to the contract owner and the fee collector." + } + }, + "notice": "This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. Part of this fee is given to the creator of the pool as an Admin fee, the amount of which is set when the pool is created. Saddle will collect to 50% of these Admin fees. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 492, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 495, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1531, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 10, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 129, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1553, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool" + }, + { + "astId": 1644, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1659, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "_status", + "offset": 0, + "slot": "151", + "type": "t_uint256" + }, + { + "astId": 1702, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 7779, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "swapStorage", + "offset": 0, + "slot": "201", + "type": "t_struct(Swap)9655_storage" + }, + { + "astId": 7783, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "tokenIndexes", + "offset": 0, + "slot": "211", + "type": "t_mapping(t_address,t_uint8)" + }, + { + "astId": 33360, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "feeCollector", + "offset": 0, + "slot": "212", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_contract(IERC20)3311)dyn_storage": { + "base": "t_contract(IERC20)3311", + "encoding": "dynamic_array", + "label": "contract IERC20[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_array(t_uint256)dyn_storage": { + "base": "t_uint256", + "encoding": "dynamic_array", + "label": "uint256[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)3311": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(LPToken)7402": { + "encoding": "inplace", + "label": "contract LPToken", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint8)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint8)", + "numberOfBytes": "32", + "value": "t_uint8" + }, + "t_struct(Swap)9655_storage": { + "encoding": "inplace", + "label": "struct SwapUtils.Swap", + "members": [ + { + "astId": 9633, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "initialA", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 9635, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "futureA", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 9637, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "initialATime", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 9639, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "futureATime", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 9641, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "swapFee", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 9643, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "adminFee", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 9645, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "lpToken", + "offset": 0, + "slot": "6", + "type": "t_contract(LPToken)7402" + }, + { + "astId": 9648, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "pooledTokens", + "offset": 0, + "slot": "7", + "type": "t_array(t_contract(IERC20)3311)dyn_storage" + }, + { + "astId": 9651, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "tokenPrecisionMultipliers", + "offset": 0, + "slot": "8", + "type": "t_array(t_uint256)dyn_storage" + }, + { + "astId": 9654, + "contract": "contracts/permissionless/PermissionlessSwap.sol:PermissionlessSwap", + "label": "balances", + "offset": 0, + "slot": "9", + "type": "t_array(t_uint256)dyn_storage" + } + ], + "numberOfBytes": "320" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/PoolRegistry.json b/deployments/base_testnet/PoolRegistry.json new file mode 100644 index 00000000..ce45e6ae --- /dev/null +++ b/deployments/base_testnet/PoolRegistry.json @@ -0,0 +1,1969 @@ +{ + "address": "0xab374155A7B6cA520D23De8db6a85471cEafB620", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "internalType": "address", + "name": "poolOwner", + "type": "address" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct IPoolRegistry.PoolData", + "name": "poolData", + "type": "tuple" + } + ], + "name": "AddCommunityPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct IPoolRegistry.PoolData", + "name": "poolData", + "type": "tuple" + } + ], + "name": "AddPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "RemovePool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "indexed": false, + "internalType": "struct IPoolRegistry.PoolData", + "name": "poolData", + "type": "tuple" + } + ], + "name": "UpdatePool", + "type": "event" + }, + { + "inputs": [], + "name": "COMMUNITY_MANAGER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SADDLE_APPROVED_POOL_OWNER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SADDLE_MANAGER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolData", + "name": "data", + "type": "tuple" + } + ], + "name": "addCommunityPool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolInputData", + "name": "inputData", + "type": "tuple" + } + ], + "name": "addPool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "approvePool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "calls", + "type": "bytes[]" + }, + { + "internalType": "bool", + "name": "revertOnFail", + "type": "bool" + } + ], + "name": "batch", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getA", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "getEligiblePools", + "outputs": [ + { + "internalType": "address[]", + "name": "eligiblePools", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getPoolData", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getPoolDataAtIndex", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + } + ], + "name": "getPoolDataByName", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolsLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getRoleMember", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleMemberCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getSwapStorage", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "initialA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + } + ], + "internalType": "struct IPoolRegistry.SwapStorageData", + "name": "swapStorageData", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getTokenBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getUnderlyingTokenBalances", + "outputs": [ + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getUnderlyingTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "getVirtualPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "poolsIndexOfNamePlusOne", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "poolsIndexOfPlusOne", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "removePool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "lpToken", + "type": "address" + }, + { + "internalType": "uint8", + "name": "typeOfAsset", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "poolName", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "targetAddress", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IERC20[]", + "name": "underlyingTokens", + "type": "address[]" + }, + { + "internalType": "address", + "name": "basePoolAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "metaSwapDepositAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "isSaddleApproved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isRemoved", + "type": "bool" + }, + { + "internalType": "bool", + "name": "isGuarded", + "type": "bool" + } + ], + "internalType": "struct IPoolRegistry.PoolData", + "name": "poolData", + "type": "tuple" + } + ], + "name": "updatePool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x4c2df69a2fba9a3166f12d921bd0b8e2208b4cf380f8412059d25a5b01234115", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0xab374155A7B6cA520D23De8db6a85471cEafB620", + "transactionIndex": 4, + "gasUsed": "4035866", + "logsBloom": "0x00000004000400020000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000020000000000000000000800010000100000000000000000000000000200000000000000000000000000000000000000000000000400000000000000000000010000000000000000000000000000000000000000001000000000000000000020000000000000000000000000000000000000000100000000000020000000000000000000000000000000000000000000000080000000000000000000", + "blockHash": "0xc045d1e1cc478c288ec789dad9a660c3b0182e57cb783556a2d6c7148368adc0", + "transactionHash": "0x4c2df69a2fba9a3166f12d921bd0b8e2208b4cf380f8412059d25a5b01234115", + "logs": [ + { + "transactionIndex": 4, + "blockNumber": 2717060, + "transactionHash": "0x4c2df69a2fba9a3166f12d921bd0b8e2208b4cf380f8412059d25a5b01234115", + "address": "0xab374155A7B6cA520D23De8db6a85471cEafB620", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 3, + "blockHash": "0xc045d1e1cc478c288ec789dad9a660c3b0182e57cb783556a2d6c7148368adc0" + }, + { + "transactionIndex": 4, + "blockNumber": 2717060, + "transactionHash": "0x4c2df69a2fba9a3166f12d921bd0b8e2208b4cf380f8412059d25a5b01234115", + "address": "0xab374155A7B6cA520D23De8db6a85471cEafB620", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0xe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 4, + "blockHash": "0xc045d1e1cc478c288ec789dad9a660c3b0182e57cb783556a2d6c7148368adc0" + }, + { + "transactionIndex": 4, + "blockNumber": 2717060, + "transactionHash": "0x4c2df69a2fba9a3166f12d921bd0b8e2208b4cf380f8412059d25a5b01234115", + "address": "0xab374155A7B6cA520D23De8db6a85471cEafB620", + "topics": [ + "0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d", + "0x3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c26", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "0x0000000000000000000000005bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34" + ], + "data": "0x", + "logIndex": 5, + "blockHash": "0xc045d1e1cc478c288ec789dad9a660c3b0182e57cb783556a2d6c7148368adc0" + } + ], + "blockNumber": 2717060, + "cumulativeGasUsed": "6389722", + "status": 1, + "byzantium": true + }, + "args": [ + "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34" + ], + "numDeployments": 1, + "solcInputHash": "bc3a64a5cffb1e8de0dbf9fb306e4f9f", + "metadata": "{\"compiler\":{\"version\":\"0.6.12+commit.27d51765\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"poolOwner\",\"type\":\"address\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"indexed\":false,\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"poolData\",\"type\":\"tuple\"}],\"name\":\"AddCommunityPool\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"indexed\":false,\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"poolData\",\"type\":\"tuple\"}],\"name\":\"AddPool\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"RemovePool\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"indexed\":false,\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"poolData\",\"type\":\"tuple\"}],\"name\":\"UpdatePool\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"COMMUNITY_MANAGER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SADDLE_APPROVED_POOL_OWNER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SADDLE_MANAGER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"data\",\"type\":\"tuple\"}],\"name\":\"addCommunityPool\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolInputData\",\"name\":\"inputData\",\"type\":\"tuple\"}],\"name\":\"addPool\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"approvePool\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"calls\",\"type\":\"bytes[]\"},{\"internalType\":\"bool\",\"name\":\"revertOnFail\",\"type\":\"bool\"}],\"name\":\"batch\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"getEligiblePools\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"eligiblePools\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getPoolData\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getPoolDataAtIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"}],\"name\":\"getPoolDataByName\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPoolsLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getSwapStorage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"initialA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initialATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"}],\"internalType\":\"struct IPoolRegistry.SwapStorageData\",\"name\":\"swapStorageData\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getTokenBalances\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"balances\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getTokens\",\"outputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getUnderlyingTokenBalances\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"balances\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getUnderlyingTokens\",\"outputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"getVirtualPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"poolsIndexOfNamePlusOne\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"poolsIndexOfPlusOne\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"}],\"name\":\"removePool\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"lpToken\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"typeOfAsset\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"poolName\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"targetAddress\",\"type\":\"address\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"contract IERC20[]\",\"name\":\"underlyingTokens\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"basePoolAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"metaSwapDepositAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isSaddleApproved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isRemoved\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"isGuarded\",\"type\":\"bool\"}],\"internalType\":\"struct IPoolRegistry.PoolData\",\"name\":\"poolData\",\"type\":\"tuple\"}],\"name\":\"updatePool\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"AddCommunityPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"params\":{\"index\":\"index of the added pool in the pools list\",\"poolAddress\":\"address of the added pool\",\"poolData\":\"added pool data\"}},\"AddPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"params\":{\"index\":\"index of the added pool in the pools list\",\"poolAddress\":\"address of the added pool\",\"poolData\":\"added pool data\"}},\"RemovePool(address,uint256)\":{\"params\":{\"index\":\"index of the removed pool in the pools list\",\"poolAddress\":\"address of the removed pool\"}},\"UpdatePool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"params\":{\"index\":\"index of the updated pool in the pools list\",\"poolAddress\":\"address of the updated pool\",\"poolData\":\"updated pool data\"}}},\"kind\":\"dev\",\"methods\":{\"addCommunityPool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"details\":\"Before adding a meta pool, the user must first add the underlying base pool. Only Swap and MetaSwap contracts need to be added.\",\"params\":{\"data\":\"PoolInputData struct for the new pool\"}},\"addPool((address,uint8,bytes32,address,address,bool,bool,bool))\":{\"details\":\"Before adding a meta pool, the user must first add the underlying base pool. Only Swap and MetaSwap contracts need to be added.\",\"params\":{\"inputData\":\"PoolInputData struct for the new pool\"}},\"approvePool(address)\":{\"details\":\"since array entries are difficult to remove, we modify the entry to mark it as a Saddle owned pool.\",\"params\":{\"poolAddress\":\"address of the community pool\"}},\"batch(bytes[],bool)\":{\"params\":{\"calls\":\"An array of inputs for each call.\",\"revertOnFail\":\"If True then reverts after a failed call and stops doing further calls.\"}},\"constructor\":{\"details\":\"caller of this function will be set as the owner on deployment\",\"params\":{\"admin\":\"address who should have the DEFAULT_ADMIN_ROLE\"}},\"getA(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getEligiblePools(address,address)\":{\"params\":{\"from\":\"address of the token to swap from\",\"to\":\"address of the token to swap to\"},\"returns\":{\"eligiblePools\":\"array of pool addresses that can swap between from and to\"}},\"getPaused(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getPoolData(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getPoolDataAtIndex(uint256)\":{\"params\":{\"index\":\"index of the pool to read\"}},\"getPoolDataByName(bytes32)\":{\"params\":{\"poolName\":\"name of the pool to read\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"getSwapStorage(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getTokenBalances(address)\":{\"params\":{\"poolAddress\":\"address of the pool to look up the token balances for\"},\"returns\":{\"balances\":\"array of token balances\"}},\"getTokens(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getUnderlyingTokenBalances(address)\":{\"params\":{\"poolAddress\":\"address of the pool to look up the token balances for\"},\"returns\":{\"balances\":\"array of token balances\"}},\"getUnderlyingTokens(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"getVirtualPrice(address)\":{\"params\":{\"poolAddress\":\"address of the pool to read\"}},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"removePool(address)\":{\"details\":\"Since arrays are not easily reducable, the entry will be marked as removed.\",\"params\":{\"poolAddress\":\"address of the pool to remove\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"},\"updatePool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"params\":{\"poolData\":\"new PoolData struct to store\"}}},\"stateVariables\":{\"poolsIndexOfNamePlusOne\":{\"params\":{\"poolName\":\"pool name in bytes32 format to look for\"}},\"poolsIndexOfPlusOne\":{\"params\":{\"poolAddress\":\"address to look for\"}}},\"title\":\"PoolRegistry\",\"version\":1},\"userdoc\":{\"events\":{\"AddCommunityPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"notice\":\"Add a new registry entry to the master list.\"},\"AddPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"notice\":\"Add a new registry entry to the master list.\"},\"RemovePool(address,uint256)\":{\"notice\":\"Add a new registry entry to the master list.\"},\"UpdatePool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"notice\":\"Add a new registry entry to the master list.\"}},\"kind\":\"user\",\"methods\":{\"COMMUNITY_MANAGER_ROLE()\":{\"notice\":\"Role responsible for managing community pools\"},\"SADDLE_APPROVED_POOL_OWNER_ROLE()\":{\"notice\":\"Role that represents approved owners of pools. owner of each pool must have this role if the pool is to be approved.\"},\"SADDLE_MANAGER_ROLE()\":{\"notice\":\"Role responsible for managing pools.\"},\"addCommunityPool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"notice\":\"Add a new pool to the registry\"},\"addPool((address,uint8,bytes32,address,address,bool,bool,bool))\":{\"notice\":\"Add a new pool to the registry\"},\"approvePool(address)\":{\"notice\":\"Approve community deployed pools to be upgraded as Saddle owned\"},\"batch(bytes[],bool)\":{\"notice\":\"Allows batched call to self (this contract).\"},\"constructor\":\"Deploy this contract and set appropriate roles\",\"getA(address)\":{\"notice\":\"Returns A of the given pool address\"},\"getEligiblePools(address,address)\":{\"notice\":\"Returns an array of pool addresses that can swap between from and to\"},\"getPaused(address)\":{\"notice\":\"Returns the paused status of the given pool address\"},\"getPoolData(address)\":{\"notice\":\"Returns PoolData for given pool address\"},\"getPoolDataAtIndex(uint256)\":{\"notice\":\"Returns PoolData at given index\"},\"getPoolDataByName(bytes32)\":{\"notice\":\"Returns PoolData with given name\"},\"getPoolsLength()\":{\"notice\":\"Returns number of entries in the registry. Includes removed pools in the list as well.\"},\"getSwapStorage(address)\":{\"notice\":\"Returns the SwapStorage struct of the given pool address\"},\"getTokenBalances(address)\":{\"notice\":\"Returns an array of balances of the tokens\"},\"getTokens(address)\":{\"notice\":\"Returns the tokens of the given pool address\"},\"getUnderlyingTokenBalances(address)\":{\"notice\":\"Returns an array of balances of the tokens\"},\"getUnderlyingTokens(address)\":{\"notice\":\"Returns the underlying tokens of the given pool address. Base pools will return an empty array.\"},\"getVirtualPrice(address)\":{\"notice\":\"Returns virtual price of the given pool address\"},\"poolsIndexOfNamePlusOne(bytes32)\":{\"notice\":\"Returns the index + 1 of the pool name in the registry\"},\"poolsIndexOfPlusOne(address)\":{\"notice\":\"Returns the index + 1 of the pool address in the registry\"},\"removePool(address)\":{\"notice\":\"Remove pool from the registry\"},\"updatePool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))\":{\"notice\":\"Overwrite existing entry with new PoolData\"}},\"notice\":\"This contract holds list of pools deployed.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/registries/PoolRegistry.sol\":\"PoolRegistry\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/Initializable.sol\\\";\\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 initializer {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal initializer {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xb419e68addcb82ecda3ad3974b0d2db76435ce9b08435a04d5b119a0c5d45ea5\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMathUpgradeable {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0x0dd1e9b19801e3e7d900fbf4182d81e1afd23ad7be39504e33df6bbcba91d724\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-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 */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !AddressUpgradeable.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0xd8e4eb08dcc1d1860fb347ba5ffd595242b9a1b66d49a47f2b4cb51c3f35017e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./ERC20Upgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal initializer {\\n __Context_init_unchained();\\n __ERC20Burnable_init_unchained();\\n }\\n\\n function __ERC20Burnable_init_unchained() internal initializer {\\n }\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \\\"ERC20: burn amount exceeds allowance\\\");\\n\\n _approve(account, _msgSender(), decreasedAllowance);\\n _burn(account, amount);\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xd0359e87fe2618573f49a95e13d9dbc31521ad64526b135618abb2a2dc362fbe\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"../../math/SafeMathUpgradeable.sol\\\";\\nimport \\\"../../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n uint256[44] private __gap;\\n}\\n\",\"keccak256\":\"0x506dd0718f9ace50588c13848167df5e04ae16abb56341afb10c31ff149bc79b\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xa1931c47a617014f858580db625aa0dcf343796f39acd4b5b51effc092a1f0a9\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary 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 function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfc5ea91fa9ceb1961023b2a6c978b902888c52b90847ac7813fe3b79524165f6\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/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 GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal initializer {\\n __Context_init_unchained();\\n }\\n\\n function __Context_init_unchained() internal initializer {\\n }\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0xbbf8a21b9a66c48d45ff771b8563c6df19ba451d63dfb8380a865c1e1f29d1a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\nimport \\\"../proxy/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuardUpgradeable is Initializable {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n function __ReentrancyGuard_init() internal initializer {\\n __ReentrancyGuard_init_unchained();\\n }\\n\\n function __ReentrancyGuard_init_unchained() internal initializer {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x46034cd5cca740f636345c8f7aebae0f78adfd4b70e31e6f888cccbe1086586e\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/AccessControl.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/EnumerableSet.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControl is Context {\\n using EnumerableSet for EnumerableSet.AddressSet;\\n using Address for address;\\n\\n struct RoleData {\\n EnumerableSet.AddressSet members;\\n bytes32 adminRole;\\n }\\n\\n mapping (bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view returns (bool) {\\n return _roles[role].members.contains(account);\\n }\\n\\n /**\\n * @dev Returns the number of accounts that have `role`. Can be used\\n * together with {getRoleMember} to enumerate all bearers of a role.\\n */\\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\\n return _roles[role].members.length();\\n }\\n\\n /**\\n * @dev Returns one of the accounts that have `role`. `index` must be a\\n * value between 0 and {getRoleMemberCount}, non-inclusive.\\n *\\n * Role bearers are not sorted in any particular way, and their ordering may\\n * change at any point.\\n *\\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\\n * you perform all queries on the same block. See the following\\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\\n * for more information.\\n */\\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\\n return _roles[role].members.at(index);\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to grant\\\");\\n\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) public virtual {\\n require(hasRole(_roles[role].adminRole, _msgSender()), \\\"AccessControl: sender must be an admin to revoke\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) public virtual {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\\n _roles[role].adminRole = adminRole;\\n }\\n\\n function _grantRole(bytes32 role, address account) private {\\n if (_roles[role].members.add(account)) {\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n function _revokeRole(bytes32 role, address account) private {\\n if (_roles[role].members.remove(account)) {\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc155a2f7837603d69a13cfa481eb5e7f5e02cb77e2ec9edbac30986db37988\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\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 () internal {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n}\\n\",\"keccak256\":\"0x15e2d5bd4c28a88548074c54d220e8086f638a71ed07e6b3ba5a70066fcf458d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xcc78a17dd88fa5a2edc60c8489e2f405c0913b377216a5b26b35656b2d0dab52\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) public {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0xca0c2396dbeb3503b51abf4248ebf77a1461edad513c01529df51850a012bee3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.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 SafeMath for uint256;\\n using Address for address;\\n\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) 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(IERC20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\\n require((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(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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) { // Return data is optional\\n // solhint-disable-next-line max-line-length\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf12dfbe97e6276980b83d2830bb0eb75e0cf4f3e626c2471137f82158ae6a0fc\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.2 <0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x28911e614500ae7c607a432a709d35da25f3bc5ddc8bd12b278b66358070c0ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x1562cd9922fbf739edfb979f506809e2743789cbde3177515542161c3d04b164\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor () internal {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x8bbbc2f5c10065ee272592ae0a7a6ceb23de2fbd81564ee0bb015ecf404d5f61\",\"license\":\"MIT\"},\"contracts/LPToken.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwap.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPToken is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n using SafeMathUpgradeable for uint256;\\n\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x8b16a37e14fd2d387dac20bf1773522b7667402f27a4b301617b928d7b998ac5\",\"license\":\"MIT\"},\"contracts/helper/BaseBoringBatchable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity 0.6.12;\\npragma experimental ABIEncoderV2;\\n\\n// solhint-disable avoid-low-level-calls\\n// solhint-disable no-inline-assembly\\n\\n// Audit on 5-Jan-2021 by Keno and BoringCrypto\\n// WARNING!!!\\n// Combining BoringBatchable with msg.value can cause double spending issues\\n// https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong/\\n\\ncontract BaseBoringBatchable {\\n /// @dev Helper function to extract a useful revert message from a failed call.\\n /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.\\n function _getRevertMsg(bytes memory _returnData)\\n internal\\n pure\\n returns (string memory)\\n {\\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\\n if (_returnData.length < 68) return \\\"Transaction reverted silently\\\";\\n\\n assembly {\\n // Slice the sighash.\\n _returnData := add(_returnData, 0x04)\\n }\\n return abi.decode(_returnData, (string)); // All that remains is the revert string\\n }\\n\\n /// @notice Allows batched call to self (this contract).\\n /// @param calls An array of inputs for each call.\\n /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.\\n // F1: External is ok here because this is the batch function, adding it to a batch makes no sense\\n // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value\\n // C3: The length of the loop is fully under user control, so can't be exploited\\n // C7: Delegatecall is only used on the same contract, so it's safe\\n function batch(bytes[] calldata calls, bool revertOnFail) external payable {\\n for (uint256 i = 0; i < calls.length; i++) {\\n (bool success, bytes memory result) = address(this).delegatecall(\\n calls[i]\\n );\\n if (!success && revertOnFail) {\\n revert(_getRevertMsg(result));\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x95f34c0ce5cd71071698709dd23eea9b6031fe973be9d6f53f9f08452a444d66\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlist.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\ninterface IAllowlist {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xf55e4d678d05bc5d0e24ec5f24504d7437b885e19579f9d29152748c3c1c732e\",\"license\":\"MIT\"},\"contracts/interfaces/IMetaSwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./ISwap.sol\\\";\\n\\ninterface IMetaSwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function isGuarded() external view returns (bool);\\n\\n function metaSwapStorage()\\n external\\n view\\n returns (\\n address baseSwap,\\n uint256 baseVirtualPrice,\\n uint256 baseCacheLastUpdated\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateSwapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function initializeMetaSwap(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress,\\n ISwap baseSwap\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function swapUnderlying(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x9392f53aaf25e15dbe85bf92477c1bf526ab70c00c5e4cd389da8e12e061c1d1\",\"license\":\"MIT\"},\"contracts/interfaces/IPoolRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IPoolRegistry {\\n /* Structs */\\n\\n struct PoolInputData {\\n address poolAddress;\\n uint8 typeOfAsset;\\n bytes32 poolName;\\n address targetAddress;\\n address metaSwapDepositAddress;\\n bool isSaddleApproved;\\n bool isRemoved;\\n bool isGuarded;\\n }\\n\\n struct PoolData {\\n address poolAddress;\\n address lpToken;\\n uint8 typeOfAsset;\\n bytes32 poolName;\\n address targetAddress;\\n IERC20[] tokens;\\n IERC20[] underlyingTokens;\\n address basePoolAddress;\\n address metaSwapDepositAddress;\\n bool isSaddleApproved;\\n bool isRemoved;\\n bool isGuarded;\\n }\\n\\n struct SwapStorageData {\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n uint256 swapFee;\\n uint256 adminFee;\\n address lpToken;\\n }\\n\\n /* Public Variables */\\n\\n /**\\n * @notice Returns the index + 1 of the pool address in the registry\\n * @param poolAddress address to look for\\n */\\n function poolsIndexOfPlusOne(address poolAddress)\\n external\\n returns (uint256);\\n\\n /**\\n * @notice Returns the index + 1 of the pool name in the registry\\n * @param poolName pool name in bytes32 format to look for\\n */\\n function poolsIndexOfNamePlusOne(bytes32 poolName)\\n external\\n returns (uint256);\\n\\n /* Functions */\\n\\n /**\\n * @notice Add a new pool to the registry\\n * @param inputData PoolInputData struct for the new pool\\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\\n * Only Swap and MetaSwap contracts need to be added.\\n */\\n function addPool(PoolInputData memory inputData) external payable;\\n\\n /**\\n * @notice Add a new pool to the registry\\n * @param data PoolInputData struct for the new pool\\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\\n * Only Swap and MetaSwap contracts need to be added.\\n */\\n function addCommunityPool(PoolData memory data) external payable;\\n\\n /**\\n * @notice Approve community deployed pools to be upgraded as Saddle owned\\n * @dev since array entries are difficult to remove, we modify the entry to mark it\\n * as a Saddle owned pool.\\n * @param poolAddress address of the community pool\\n */\\n function approvePool(address poolAddress) external payable;\\n\\n /**\\n * @notice Overwrite existing entry with new PoolData\\n * @param poolData new PoolData struct to store\\n */\\n function updatePool(PoolData memory poolData) external payable;\\n\\n /**\\n * @notice Remove pool from the registry\\n * @dev Since arrays are not easily reducable, the entry will be marked as removed.\\n * @param poolAddress address of the pool to remove\\n */\\n function removePool(address poolAddress) external payable;\\n\\n /**\\n * @notice Returns PoolData for given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getPoolData(address poolAddress)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns PoolData at given index\\n * @param index index of the pool to read\\n */\\n function getPoolDataAtIndex(uint256 index)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns PoolData with given name\\n * @param poolName name of the pool to read\\n */\\n function getPoolDataByName(bytes32 poolName)\\n external\\n view\\n returns (PoolData memory);\\n\\n /**\\n * @notice Returns virtual price of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getVirtualPrice(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n /**\\n * @notice Returns A of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getA(address poolAddress) external view returns (uint256);\\n\\n /**\\n * @notice Returns the paused status of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getPaused(address poolAddress) external view returns (bool);\\n\\n /**\\n * @notice Returns the SwapStorage struct of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getSwapStorage(address poolAddress)\\n external\\n view\\n returns (SwapStorageData memory swapStorageData);\\n\\n /**\\n * @notice Returns the tokens of the given pool address\\n * @param poolAddress address of the pool to read\\n */\\n function getTokens(address poolAddress)\\n external\\n view\\n returns (IERC20[] memory);\\n\\n /**\\n * @notice Returns the underlying tokens of the given pool address. Base pools will return an empty array.\\n * @param poolAddress address of the pool to read\\n */\\n function getUnderlyingTokens(address poolAddress)\\n external\\n view\\n returns (IERC20[] memory);\\n\\n /**\\n * @notice Returns number of entries in the registry. Includes removed pools\\n * in the list as well.\\n */\\n function getPoolsLength() external view returns (uint256);\\n\\n /**\\n * @notice Returns an array of pool addresses that can swap between from and to\\n * @param from address of the token to swap from\\n * @param to address of the token to swap to\\n * @return eligiblePools array of pool addresses that can swap between from and to\\n */\\n function getEligiblePools(address from, address to)\\n external\\n view\\n returns (address[] memory eligiblePools);\\n\\n /**\\n * @notice Returns an array of balances of the tokens\\n * @param poolAddress address of the pool to look up the token balances for\\n * @return balances array of token balances\\n */\\n function getTokenBalances(address poolAddress)\\n external\\n view\\n returns (uint256[] memory balances);\\n\\n /**\\n * @notice Returns an array of balances of the tokens\\n * @param poolAddress address of the pool to look up the token balances for\\n * @return balances array of token balances\\n */\\n function getUnderlyingTokenBalances(address poolAddress)\\n external\\n view\\n returns (uint256[] memory balances);\\n}\\n\",\"keccak256\":\"0x7f51230d9e9229a935312bd05f5e93ab8fbb38e6635bbfb9402001b86a795bb2\",\"license\":\"MIT\"},\"contracts/interfaces/ISwap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlist.sol\\\";\\n\\ninterface ISwap {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlist);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xcd26195c5e3824e7984750a05c9fcb6dde3e266022c3bd1a9dcdda9e967a6f4c\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapGuarded.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlist.sol\\\";\\n\\ninterface ISwapGuarded {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlist);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function isGuarded() external view returns (bool);\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline,\\n bytes32[] calldata merkleProof\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n // withdraw fee update function\\n function updateUserWithdrawFee(address recipient, uint256 transferAmount)\\n external;\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256 initialA,\\n uint256 futureA,\\n uint256 initialATime,\\n uint256 futureATime,\\n uint256 swapFee,\\n uint256 adminFee,\\n uint256 defaultWithdrawFee,\\n address lpToken\\n );\\n}\\n\",\"keccak256\":\"0x9693ff0a334f1df8e3e1f08ddf9580299b247117028268bf8437576e0d534bc7\",\"license\":\"MIT\"},\"contracts/meta/MetaSwapDeposit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\\\";\\nimport \\\"../LPToken.sol\\\";\\nimport \\\"../interfaces/ISwap.sol\\\";\\nimport \\\"../interfaces/IMetaSwap.sol\\\";\\n\\n/**\\n * @title MetaSwapDeposit\\n * @notice This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be\\n * deployed before this contract can be initialized successfully.\\n *\\n * For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT].\\n * Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either\\n * the LP token or the underlying tokens and sUSD.\\n *\\n * MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users\\n * to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act\\n * as a Swap containing [sUSD, DAI, USDC, USDT] tokens.\\n */\\ncontract MetaSwapDeposit is Initializable, ReentrancyGuardUpgradeable {\\n using SafeERC20 for IERC20;\\n using SafeMath for uint256;\\n\\n ISwap public baseSwap;\\n IMetaSwap public metaSwap;\\n IERC20[] public baseTokens;\\n IERC20[] public metaTokens;\\n IERC20[] public tokens;\\n IERC20 public metaLPToken;\\n\\n uint256 constant MAX_UINT256 = 2**256 - 1;\\n\\n struct RemoveLiquidityImbalanceInfo {\\n ISwap baseSwap;\\n IMetaSwap metaSwap;\\n IERC20 metaLPToken;\\n uint8 baseLPTokenIndex;\\n bool withdrawFromBase;\\n uint256 leftoverMetaLPTokenAmount;\\n }\\n\\n /**\\n * @notice Sets the address for the base Swap contract, MetaSwap contract, and the\\n * MetaSwap LP token contract.\\n * @param _baseSwap the address of the base Swap contract\\n * @param _metaSwap the address of the MetaSwap contract\\n * @param _metaLPToken the address of the MetaSwap LP token contract\\n */\\n function initialize(\\n ISwap _baseSwap,\\n IMetaSwap _metaSwap,\\n IERC20 _metaLPToken\\n ) external initializer {\\n __ReentrancyGuard_init();\\n // Check and approve base level tokens to be deposited to the base Swap contract\\n {\\n uint8 i;\\n for (; i < 32; i++) {\\n try _baseSwap.getToken(i) returns (IERC20 token) {\\n baseTokens.push(token);\\n token.safeApprove(address(_baseSwap), MAX_UINT256);\\n token.safeApprove(address(_metaSwap), MAX_UINT256);\\n } catch {\\n break;\\n }\\n }\\n require(i > 1, \\\"baseSwap must have at least 2 tokens\\\");\\n }\\n\\n // Check and approve meta level tokens to be deposited to the MetaSwap contract\\n IERC20 baseLPToken;\\n {\\n uint8 i;\\n for (; i < 32; i++) {\\n try _metaSwap.getToken(i) returns (IERC20 token) {\\n baseLPToken = token;\\n metaTokens.push(token);\\n tokens.push(token);\\n token.safeApprove(address(_metaSwap), MAX_UINT256);\\n } catch {\\n break;\\n }\\n }\\n require(i > 1, \\\"metaSwap must have at least 2 tokens\\\");\\n }\\n\\n // Flatten baseTokens and append it to tokens array\\n tokens[tokens.length - 1] = baseTokens[0];\\n for (uint8 i = 1; i < baseTokens.length; i++) {\\n tokens.push(baseTokens[i]);\\n }\\n\\n // Approve base Swap LP token to be burned by the base Swap contract for withdrawing\\n baseLPToken.safeApprove(address(_baseSwap), MAX_UINT256);\\n // Approve MetaSwap LP token to be burned by the MetaSwap contract for withdrawing\\n _metaLPToken.safeApprove(address(_metaSwap), MAX_UINT256);\\n\\n // Initialize storage variables\\n baseSwap = _baseSwap;\\n metaSwap = _metaSwap;\\n metaLPToken = _metaLPToken;\\n }\\n\\n // Mutative functions\\n\\n /**\\n * @notice Swap two underlying tokens using the meta pool and the base pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n tokens[tokenIndexFrom].safeTransferFrom(msg.sender, address(this), dx);\\n uint256 tokenToAmount = metaSwap.swapUnderlying(\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n minDy,\\n deadline\\n );\\n tokens[tokenIndexTo].safeTransfer(msg.sender, tokenToAmount);\\n return tokenToAmount;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n // Read to memory to save on gas\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\\n\\n require(amounts.length == memBaseTokens.length + baseLPTokenIndex);\\n\\n uint256 baseLPTokenAmount;\\n {\\n // Transfer base tokens from the caller and deposit to the base Swap pool\\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\\n bool shouldDepositBaseTokens;\\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\\n IERC20 token = memBaseTokens[i];\\n uint256 depositAmount = amounts[baseLPTokenIndex + i];\\n if (depositAmount > 0) {\\n token.safeTransferFrom(\\n msg.sender,\\n address(this),\\n depositAmount\\n );\\n baseAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\\n // if there are any base Swap level tokens, flag it for deposits\\n shouldDepositBaseTokens = true;\\n }\\n }\\n if (shouldDepositBaseTokens) {\\n // Deposit any base Swap level tokens and receive baseLPToken\\n baseLPTokenAmount = baseSwap.addLiquidity(\\n baseAmounts,\\n 0,\\n deadline\\n );\\n }\\n }\\n\\n uint256 metaLPTokenAmount;\\n {\\n // Transfer remaining meta level tokens from the caller\\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n IERC20 token = memMetaTokens[i];\\n uint256 depositAmount = amounts[i];\\n if (depositAmount > 0) {\\n token.safeTransferFrom(\\n msg.sender,\\n address(this),\\n depositAmount\\n );\\n metaAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\\n }\\n }\\n // Update the baseLPToken amount that will be deposited\\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\\n\\n // Deposit the meta level tokens and the baseLPToken\\n metaLPTokenAmount = metaSwap.addLiquidity(\\n metaAmounts,\\n minToMint,\\n deadline\\n );\\n }\\n\\n // Transfer the meta lp token to the caller\\n metaLPToken.safeTransfer(msg.sender, metaLPTokenAmount);\\n\\n return metaLPTokenAmount;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amounts of tokens user received\\n */\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external nonReentrant returns (uint256[] memory) {\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256[] memory totalRemovedAmounts;\\n\\n {\\n uint256 numOfAllTokens = memBaseTokens.length +\\n memMetaTokens.length -\\n 1;\\n require(minAmounts.length == numOfAllTokens, \\\"out of range\\\");\\n totalRemovedAmounts = new uint256[](numOfAllTokens);\\n }\\n\\n // Transfer meta lp token from the caller to this\\n metaLPToken.safeTransferFrom(msg.sender, address(this), amount);\\n\\n uint256 baseLPTokenAmount;\\n {\\n // Remove liquidity from the MetaSwap pool\\n uint256[] memory removedAmounts;\\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\\n {\\n uint256[] memory metaMinAmounts = new uint256[](\\n memMetaTokens.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n metaMinAmounts[i] = minAmounts[i];\\n }\\n removedAmounts = metaSwap.removeLiquidity(\\n amount,\\n metaMinAmounts,\\n deadline\\n );\\n }\\n\\n // Send the meta level tokens to the caller\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n totalRemovedAmounts[i] = removedAmounts[i];\\n memMetaTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\\n }\\n baseLPTokenAmount = removedAmounts[baseLPTokenIndex];\\n\\n // Remove liquidity from the base Swap pool\\n {\\n uint256[] memory baseMinAmounts = new uint256[](\\n memBaseTokens.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];\\n }\\n removedAmounts = baseSwap.removeLiquidity(\\n baseLPTokenAmount,\\n baseMinAmounts,\\n deadline\\n );\\n }\\n\\n // Send the base level tokens to the caller\\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\\n totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i];\\n memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\\n }\\n }\\n\\n return totalRemovedAmounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\\n uint8 baseTokensLength = uint8(baseTokens.length);\\n\\n // Transfer metaLPToken from the caller\\n metaLPToken.safeTransferFrom(msg.sender, address(this), tokenAmount);\\n\\n IERC20 token;\\n if (tokenIndex < baseLPTokenIndex) {\\n // When the desired token is meta level token, we can just call `removeLiquidityOneToken` directly\\n metaSwap.removeLiquidityOneToken(\\n tokenAmount,\\n tokenIndex,\\n minAmount,\\n deadline\\n );\\n token = metaTokens[tokenIndex];\\n } else if (tokenIndex < baseLPTokenIndex + baseTokensLength) {\\n // When the desired token is a base level token, we need to first withdraw via baseLPToken, then withdraw\\n // the desired token from the base Swap contract.\\n uint256 removedBaseLPTokenAmount = metaSwap.removeLiquidityOneToken(\\n tokenAmount,\\n baseLPTokenIndex,\\n 0,\\n deadline\\n );\\n\\n baseSwap.removeLiquidityOneToken(\\n removedBaseLPTokenAmount,\\n tokenIndex - baseLPTokenIndex,\\n minAmount,\\n deadline\\n );\\n token = baseTokens[tokenIndex - baseLPTokenIndex];\\n } else {\\n revert(\\\"out of range\\\");\\n }\\n\\n uint256 amountWithdrawn = token.balanceOf(address(this));\\n token.safeTransfer(msg.sender, amountWithdrawn);\\n return amountWithdrawn;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external nonReentrant returns (uint256) {\\n IERC20[] memory memBaseTokens = baseTokens;\\n IERC20[] memory memMetaTokens = metaTokens;\\n uint256[] memory metaAmounts = new uint256[](memMetaTokens.length);\\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\\n\\n require(\\n amounts.length == memBaseTokens.length + memMetaTokens.length - 1,\\n \\\"out of range\\\"\\n );\\n\\n RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(\\n baseSwap,\\n metaSwap,\\n metaLPToken,\\n uint8(metaAmounts.length - 1),\\n false,\\n 0\\n );\\n\\n for (uint8 i = 0; i < v.baseLPTokenIndex; i++) {\\n metaAmounts[i] = amounts[i];\\n }\\n\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n baseAmounts[i] = amounts[v.baseLPTokenIndex + i];\\n if (baseAmounts[i] > 0) {\\n v.withdrawFromBase = true;\\n }\\n }\\n\\n // Calculate how much base LP token we need to get the desired amount of underlying tokens\\n if (v.withdrawFromBase) {\\n metaAmounts[v.baseLPTokenIndex] = v\\n .baseSwap\\n .calculateTokenAmount(baseAmounts, false)\\n .mul(10005)\\n .div(10000);\\n }\\n\\n // Transfer MetaSwap LP token from the caller to this contract\\n v.metaLPToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n maxBurnAmount\\n );\\n\\n // Withdraw the paired meta level tokens and the base LP token from the MetaSwap pool\\n uint256 burnedMetaLPTokenAmount = v.metaSwap.removeLiquidityImbalance(\\n metaAmounts,\\n maxBurnAmount,\\n deadline\\n );\\n v.leftoverMetaLPTokenAmount = maxBurnAmount.sub(\\n burnedMetaLPTokenAmount\\n );\\n\\n // If underlying tokens are desired, withdraw them from the base Swap pool\\n if (v.withdrawFromBase) {\\n v.baseSwap.removeLiquidityImbalance(\\n baseAmounts,\\n metaAmounts[v.baseLPTokenIndex],\\n deadline\\n );\\n\\n // Base Swap may require LESS base LP token than the amount we have\\n // In that case, deposit it to the MetaSwap pool.\\n uint256[] memory leftovers = new uint256[](metaAmounts.length);\\n IERC20 baseLPToken = memMetaTokens[v.baseLPTokenIndex];\\n uint256 leftoverBaseLPTokenAmount = baseLPToken.balanceOf(\\n address(this)\\n );\\n if (leftoverBaseLPTokenAmount > 0) {\\n leftovers[v.baseLPTokenIndex] = leftoverBaseLPTokenAmount;\\n v.leftoverMetaLPTokenAmount = v.leftoverMetaLPTokenAmount.add(\\n v.metaSwap.addLiquidity(leftovers, 0, deadline)\\n );\\n }\\n }\\n\\n // Transfer all withdrawn tokens to the caller\\n for (uint8 i = 0; i < amounts.length; i++) {\\n IERC20 token;\\n if (i < v.baseLPTokenIndex) {\\n token = memMetaTokens[i];\\n } else {\\n token = memBaseTokens[i - v.baseLPTokenIndex];\\n }\\n if (amounts[i] > 0) {\\n token.safeTransfer(msg.sender, amounts[i]);\\n }\\n }\\n\\n // If there were any extra meta lp token, transfer them back to the caller as well\\n if (v.leftoverMetaLPTokenAmount > 0) {\\n v.metaLPToken.safeTransfer(msg.sender, v.leftoverMetaLPTokenAmount);\\n }\\n\\n return maxBurnAmount - v.leftoverMetaLPTokenAmount;\\n }\\n\\n // VIEW FUNCTIONS\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running. When withdrawing from the base pool in imbalanced\\n * fashion, the recommended slippage setting is 0.2% or higher.\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256)\\n {\\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\\n uint256[] memory baseAmounts = new uint256[](baseTokens.length);\\n uint256 baseLPTokenIndex = metaAmounts.length - 1;\\n\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n metaAmounts[i] = amounts[i];\\n }\\n\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n baseAmounts[i] = amounts[baseLPTokenIndex + i];\\n }\\n\\n uint256 baseLPTokenAmount = baseSwap.calculateTokenAmount(\\n baseAmounts,\\n deposit\\n );\\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\\n\\n return metaSwap.calculateTokenAmount(metaAmounts, deposit);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of LP tokens\\n * @param amount the amount of LP tokens that would be burned on withdrawal\\n * @return array of token balances that the user will receive\\n */\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n uint256[] memory metaAmounts = metaSwap.calculateRemoveLiquidity(\\n amount\\n );\\n uint8 baseLPTokenIndex = uint8(metaAmounts.length - 1);\\n uint256[] memory baseAmounts = baseSwap.calculateRemoveLiquidity(\\n metaAmounts[baseLPTokenIndex]\\n );\\n\\n uint256[] memory totalAmounts = new uint256[](\\n baseLPTokenIndex + baseAmounts.length\\n );\\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\\n totalAmounts[i] = metaAmounts[i];\\n }\\n for (uint8 i = 0; i < baseAmounts.length; i++) {\\n totalAmounts[baseLPTokenIndex + i] = baseAmounts[i];\\n }\\n\\n return totalAmounts;\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\\n\\n if (tokenIndex < baseLPTokenIndex) {\\n return\\n metaSwap.calculateRemoveLiquidityOneToken(\\n tokenAmount,\\n tokenIndex\\n );\\n } else {\\n uint256 baseLPTokenAmount = metaSwap\\n .calculateRemoveLiquidityOneToken(\\n tokenAmount,\\n baseLPTokenIndex\\n );\\n return\\n baseSwap.calculateRemoveLiquidityOneToken(\\n baseLPTokenAmount,\\n tokenIndex - baseLPTokenIndex\\n );\\n }\\n }\\n\\n /**\\n * @notice Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range.\\n * This is a flattened representation of the pooled tokens.\\n * @param index the index of the token\\n * @return address of the token at given index\\n */\\n function getToken(uint8 index) external view returns (IERC20) {\\n require(index < tokens.length, \\\"index out of range\\\");\\n return tokens[index];\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256) {\\n return\\n metaSwap.calculateSwapUnderlying(tokenIndexFrom, tokenIndexTo, dx);\\n }\\n}\\n\",\"keccak256\":\"0x0e4a1a808cf69d4efc706a098bbc0207447a6e1843350f902f23ef1fa0f9d90e\",\"license\":\"MIT\"},\"contracts/registries/PoolRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.6.12;\\npragma experimental ABIEncoderV2;\\n\\nimport \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/AccessControl.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\\\";\\nimport \\\"../helper/BaseBoringBatchable.sol\\\";\\nimport \\\"../interfaces/ISwap.sol\\\";\\nimport \\\"../interfaces/ISwapGuarded.sol\\\";\\nimport \\\"../interfaces/IMetaSwap.sol\\\";\\nimport \\\"../interfaces/IPoolRegistry.sol\\\";\\nimport \\\"../meta/MetaSwapDeposit.sol\\\";\\n\\n/**\\n * @title PoolRegistry\\n * @notice This contract holds list of pools deployed.\\n */\\ncontract PoolRegistry is\\n AccessControl,\\n ReentrancyGuard,\\n BaseBoringBatchable,\\n IPoolRegistry\\n{\\n using SafeMath for uint256;\\n\\n /// @notice Role responsible for managing pools.\\n bytes32 public constant SADDLE_MANAGER_ROLE =\\n keccak256(\\\"SADDLE_MANAGER_ROLE\\\");\\n /// @notice Role responsible for managing community pools\\n bytes32 public constant COMMUNITY_MANAGER_ROLE =\\n keccak256(\\\"COMMUNITY_MANAGER_ROLE\\\");\\n /// @notice Role that represents approved owners of pools.\\n /// owner of each pool must have this role if the pool is to be approved.\\n bytes32 public constant SADDLE_APPROVED_POOL_OWNER_ROLE =\\n keccak256(\\\"SADDLE_APPROVED_POOL_OWNER_ROLE\\\");\\n\\n /// @inheritdoc IPoolRegistry\\n mapping(address => uint256) public override poolsIndexOfPlusOne;\\n /// @inheritdoc IPoolRegistry\\n mapping(bytes32 => uint256) public override poolsIndexOfNamePlusOne;\\n\\n PoolData[] private pools;\\n mapping(uint256 => address[]) private eligiblePairsMap;\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param poolAddress address of the added pool\\n * @param index index of the added pool in the pools list\\n * @param poolData added pool data\\n */\\n event AddPool(\\n address indexed poolAddress,\\n uint256 index,\\n PoolData poolData\\n );\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param poolAddress address of the added pool\\n * @param index index of the added pool in the pools list\\n * @param poolData added pool data\\n */\\n event AddCommunityPool(\\n address indexed poolAddress,\\n uint256 index,\\n PoolData poolData\\n );\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param poolAddress address of the updated pool\\n * @param index index of the updated pool in the pools list\\n * @param poolData updated pool data\\n */\\n event UpdatePool(\\n address indexed poolAddress,\\n uint256 index,\\n PoolData poolData\\n );\\n\\n /**\\n * @notice Add a new registry entry to the master list.\\n * @param poolAddress address of the removed pool\\n * @param index index of the removed pool in the pools list\\n */\\n event RemovePool(address indexed poolAddress, uint256 index);\\n\\n /**\\n * @notice Deploy this contract and set appropriate roles\\n * @param admin address who should have the DEFAULT_ADMIN_ROLE\\n * @dev caller of this function will be set as the owner on deployment\\n */\\n constructor(address admin, address poolOwner) public payable {\\n require(admin != address(0), \\\"admin == 0\\\");\\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\\n _setupRole(SADDLE_APPROVED_POOL_OWNER_ROLE, poolOwner);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function addCommunityPool(PoolData memory data) external payable override {\\n require(\\n hasRole(COMMUNITY_MANAGER_ROLE, msg.sender),\\n \\\"PR: Only managers can add pools\\\"\\n );\\n\\n // Check token addresses\\n for (uint8 i = 0; i < data.tokens.length; i++) {\\n for (uint8 j = 0; j < i; j++) {\\n eligiblePairsMap[\\n uint160(address(data.tokens[i])) ^\\n uint160(address(data.tokens[j]))\\n ].push(data.poolAddress);\\n }\\n }\\n\\n // Check meta swap deposit address\\n if (data.metaSwapDepositAddress != address(0)) {\\n for (uint8 i = 0; i < data.underlyingTokens.length; i++) {\\n // add combinations of tokens to eligible pairs map\\n // i reprents the indexes of the underlying tokens of metaLPToken.\\n // j represents the indexes of MetaSwap level tokens that are not metaLPToken.\\n // Example: tokens = [sUSD, baseLPToken]\\n // underlyingTokens = [sUSD, DAI, USDC, USDT]\\n // i represents index of [DAI, USDC, USDT] in underlyingTokens\\n // j represents index of [sUSD] in underlyingTokens\\n if (i > data.tokens.length.sub(2))\\n for (uint256 j = 0; j < data.tokens.length - 1; j++) {\\n eligiblePairsMap[\\n uint160(address(data.underlyingTokens[i])) ^\\n uint160(address(data.underlyingTokens[j]))\\n ].push(data.metaSwapDepositAddress);\\n }\\n }\\n }\\n\\n pools.push(data);\\n poolsIndexOfPlusOne[data.poolAddress] = pools.length;\\n poolsIndexOfNamePlusOne[data.poolName] = pools.length;\\n\\n emit AddCommunityPool(data.poolAddress, pools.length - 1, data);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function addPool(PoolInputData memory inputData)\\n external\\n payable\\n override\\n nonReentrant\\n {\\n require(\\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\\n \\\"PR: Only managers can add pools\\\"\\n );\\n require(inputData.poolAddress != address(0), \\\"PR: poolAddress is 0\\\");\\n require(\\n poolsIndexOfPlusOne[inputData.poolAddress] == 0,\\n \\\"PR: Pool is already added\\\"\\n );\\n\\n IERC20[] memory tokens = new IERC20[](8);\\n IERC20[] memory underlyingTokens = new IERC20[](8);\\n\\n PoolData memory data = PoolData(\\n inputData.poolAddress,\\n address(0),\\n inputData.typeOfAsset,\\n inputData.poolName,\\n inputData.targetAddress,\\n tokens,\\n underlyingTokens,\\n address(0),\\n inputData.metaSwapDepositAddress,\\n inputData.isSaddleApproved,\\n inputData.isRemoved,\\n inputData.isGuarded\\n );\\n\\n // Get lp token address\\n data.lpToken = inputData.isGuarded\\n ? _getSwapStorageGuarded(inputData.poolAddress).lpToken\\n : _getSwapStorage(inputData.poolAddress).lpToken;\\n\\n // Check token addresses\\n for (uint8 i = 0; i < 8; i++) {\\n try ISwap(inputData.poolAddress).getToken(i) returns (\\n IERC20 token\\n ) {\\n require(address(token) != address(0), \\\"PR: token is 0\\\");\\n tokens[i] = token;\\n // add combinations of tokens to eligible pairs map\\n for (uint8 j = 0; j < i; j++) {\\n eligiblePairsMap[\\n uint160(address(tokens[i])) ^\\n uint160(address(tokens[j]))\\n ].push(inputData.poolAddress);\\n }\\n } catch {\\n assembly {\\n mstore(tokens, sub(mload(tokens), sub(8, i)))\\n }\\n break;\\n }\\n }\\n\\n // Check meta swap deposit address\\n if (inputData.metaSwapDepositAddress != address(0)) {\\n // Get base pool address\\n data.basePoolAddress = address(\\n MetaSwapDeposit(inputData.metaSwapDepositAddress).baseSwap()\\n );\\n require(\\n poolsIndexOfPlusOne[data.basePoolAddress] > 0,\\n \\\"PR: base pool not found\\\"\\n );\\n\\n // Get underlying tokens\\n for (uint8 i = 0; i < 8; i++) {\\n try\\n MetaSwapDeposit(inputData.metaSwapDepositAddress).getToken(\\n i\\n )\\n returns (IERC20 token) {\\n require(address(token) != address(0), \\\"PR: token is 0\\\");\\n underlyingTokens[i] = token;\\n // add combinations of tokens to eligible pairs map\\n // i reprents the indexes of the underlying tokens of metaLPToken.\\n // j represents the indexes of MetaSwap level tokens that are not metaLPToken.\\n // Example: tokens = [sUSD, baseLPToken]\\n // underlyingTokens = [sUSD, DAI, USDC, USDT]\\n // i represents index of [DAI, USDC, USDT] in underlyingTokens\\n // j represents index of [sUSD] in underlyingTokens\\n if (i > tokens.length.sub(2))\\n for (uint256 j = 0; j < tokens.length - 1; j++) {\\n eligiblePairsMap[\\n uint160(address(underlyingTokens[i])) ^\\n uint160(address(underlyingTokens[j]))\\n ].push(inputData.metaSwapDepositAddress);\\n }\\n } catch {\\n assembly {\\n mstore(\\n underlyingTokens,\\n sub(mload(underlyingTokens), sub(8, i))\\n )\\n }\\n break;\\n }\\n }\\n require(\\n address(\\n MetaSwapDeposit(inputData.metaSwapDepositAddress).metaSwap()\\n ) == inputData.poolAddress,\\n \\\"PR: metaSwap address mismatch\\\"\\n );\\n } else {\\n assembly {\\n mstore(underlyingTokens, sub(mload(underlyingTokens), 8))\\n }\\n }\\n\\n pools.push(data);\\n poolsIndexOfPlusOne[data.poolAddress] = pools.length;\\n poolsIndexOfNamePlusOne[data.poolName] = pools.length;\\n\\n emit AddPool(inputData.poolAddress, pools.length - 1, data);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function approvePool(address poolAddress)\\n external\\n payable\\n override\\n managerOnly\\n {\\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];\\n require(poolIndex > 0, \\\"PR: Pool not found\\\");\\n\\n PoolData storage poolData = pools[poolIndex];\\n\\n require(\\n poolData.poolAddress == poolAddress,\\n \\\"PR: poolAddress mismatch\\\"\\n );\\n\\n // Effect\\n poolData.isSaddleApproved = true;\\n\\n // Interaction\\n require(\\n hasRole(\\n SADDLE_APPROVED_POOL_OWNER_ROLE,\\n ISwap(poolAddress).owner()\\n ),\\n \\\"Pool is not owned by saddle\\\"\\n );\\n\\n emit UpdatePool(poolAddress, poolIndex, poolData);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function updatePool(PoolData memory poolData)\\n external\\n payable\\n override\\n managerOnly\\n {\\n uint256 poolIndex = poolsIndexOfPlusOne[poolData.poolAddress];\\n require(poolIndex > 0, \\\"PR: Pool not found\\\");\\n poolIndex -= 1;\\n\\n pools[poolIndex] = poolData;\\n\\n emit UpdatePool(poolData.poolAddress, poolIndex, poolData);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function removePool(address poolAddress)\\n external\\n payable\\n override\\n managerOnly\\n {\\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];\\n require(poolIndex > 0, \\\"PR: Pool not found\\\");\\n poolIndex -= 1;\\n\\n pools[poolIndex].isRemoved = true;\\n\\n emit RemovePool(poolAddress, poolIndex);\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getPoolDataAtIndex(uint256 index)\\n external\\n view\\n override\\n returns (PoolData memory)\\n {\\n require(index < pools.length, \\\"PR: Index out of bounds\\\");\\n return pools[index];\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getPoolData(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (PoolData memory)\\n {\\n return pools[poolsIndexOfPlusOne[poolAddress] - 1];\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getPoolDataByName(bytes32 poolName)\\n external\\n view\\n override\\n returns (PoolData memory)\\n {\\n uint256 index = poolsIndexOfNamePlusOne[poolName];\\n require(index > 0, \\\"PR: Pool not found\\\");\\n return pools[index - 1];\\n }\\n\\n modifier hasMatchingPool(address poolAddress) {\\n require(\\n poolsIndexOfPlusOne[poolAddress] > 0,\\n \\\"PR: No matching pool found\\\"\\n );\\n _;\\n }\\n\\n modifier managerOnly() {\\n require(\\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\\n \\\"PR: Caller is not saddle manager\\\"\\n );\\n _;\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getVirtualPrice(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (uint256)\\n {\\n return ISwap(poolAddress).getVirtualPrice();\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getA(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (uint256)\\n {\\n return ISwap(poolAddress).getA();\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getPaused(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (bool)\\n {\\n return ISwap(poolAddress).paused();\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getSwapStorage(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (SwapStorageData memory swapStorageData)\\n {\\n swapStorageData = pools[poolsIndexOfPlusOne[poolAddress] - 1].isGuarded\\n ? _getSwapStorageGuarded(poolAddress)\\n : _getSwapStorage(poolAddress);\\n }\\n\\n function _getSwapStorage(address poolAddress)\\n internal\\n view\\n returns (SwapStorageData memory swapStorageData)\\n {\\n (\\n swapStorageData.initialA,\\n swapStorageData.futureA,\\n swapStorageData.initialATime,\\n swapStorageData.futureATime,\\n swapStorageData.swapFee,\\n swapStorageData.adminFee,\\n swapStorageData.lpToken\\n ) = ISwap(poolAddress).swapStorage();\\n }\\n\\n function _getSwapStorageGuarded(address poolAddress)\\n internal\\n view\\n returns (SwapStorageData memory swapStorageData)\\n {\\n (\\n swapStorageData.initialA,\\n swapStorageData.futureA,\\n swapStorageData.initialATime,\\n swapStorageData.futureATime,\\n swapStorageData.swapFee,\\n swapStorageData.adminFee,\\n ,\\n swapStorageData.lpToken\\n ) = ISwapGuarded(poolAddress).swapStorage();\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getTokens(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (IERC20[] memory tokens)\\n {\\n return pools[poolsIndexOfPlusOne[poolAddress] - 1].tokens;\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getUnderlyingTokens(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (IERC20[] memory underlyingTokens)\\n {\\n return pools[poolsIndexOfPlusOne[poolAddress] - 1].underlyingTokens;\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getPoolsLength() external view override returns (uint256) {\\n return pools.length;\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getEligiblePools(address from, address to)\\n external\\n view\\n override\\n returns (address[] memory eligiblePools)\\n {\\n require(\\n from != address(0) && from != to,\\n \\\"PR: from and to cannot be the zero address\\\"\\n );\\n return eligiblePairsMap[uint160(from) ^ uint160(to)];\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getTokenBalances(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (uint256[] memory balances)\\n {\\n return _getTokenBalances(poolAddress);\\n }\\n\\n function _getTokenBalances(address poolAddress)\\n internal\\n view\\n returns (uint256[] memory balances)\\n {\\n uint256 tokensLength = pools[poolsIndexOfPlusOne[poolAddress] - 1]\\n .tokens\\n .length;\\n balances = new uint256[](tokensLength);\\n for (uint8 i = 0; i < tokensLength; i++) {\\n balances[i] = ISwap(poolAddress).getTokenBalance(i);\\n }\\n }\\n\\n /// @inheritdoc IPoolRegistry\\n function getUnderlyingTokenBalances(address poolAddress)\\n external\\n view\\n override\\n hasMatchingPool(poolAddress)\\n returns (uint256[] memory balances)\\n {\\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress] - 1;\\n address basePoolAddress = pools[poolIndex].basePoolAddress;\\n uint256[] memory basePoolBalances = _getTokenBalances(basePoolAddress);\\n uint256 underlyingTokensLength = pools[poolIndex]\\n .underlyingTokens\\n .length;\\n uint256 metaLPTokenIndex = underlyingTokensLength -\\n basePoolBalances.length;\\n uint256 baseLPTokenBalance = ISwap(poolAddress).getTokenBalance(\\n uint8(metaLPTokenIndex)\\n );\\n uint256 baseLPTokenTotalSupply = LPToken(\\n pools[poolsIndexOfPlusOne[basePoolAddress] - 1].lpToken\\n ).totalSupply();\\n\\n balances = new uint256[](underlyingTokensLength);\\n for (uint8 i = 0; i < metaLPTokenIndex; i++) {\\n balances[i] = ISwap(poolAddress).getTokenBalance(i);\\n }\\n for (uint256 i = metaLPTokenIndex; i < underlyingTokensLength; i++) {\\n balances[i] = basePoolBalances[i - metaLPTokenIndex]\\n .mul(baseLPTokenBalance)\\n .div(baseLPTokenTotalSupply);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x57077212f99572a085635a1cfcba3d1c6dc36d2244ecfecc169d22159f964755\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405260405162004657380380620046578339810160408190526200002691620001dd565b600180556001600160a01b0382166200005c5760405162461bcd60e51b815260040162000053906200021b565b60405180910390fd5b62000069600083620000c9565b620000957fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33620000c9565b620000c17f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2682620000c9565b505062000258565b620000d58282620000d9565b5050565b600082815260208181526040909120620000fe91839062002baf62000152821b17901c565b15620000d5576200010e62000172565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000169836001600160a01b03841662000176565b90505b92915050565b3390565b6000620001848383620001c5565b620001bc575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200016c565b5060006200016c565b60009081526001919091016020526040902054151590565b60008060408385031215620001f0578182fd5b8251620001fd816200023f565b602084015190925062000210816200023f565b809150509250929050565b6020808252600a9082015269061646d696e203d3d20360b41b604082015260600190565b6001600160a01b03811681146200025557600080fd5b50565b6143ef80620002686000396000f3fe6080604052600436106101e35760003560e01c8063764f3aa811610102578063b55d990411610095578063d2423b5111610064578063d2423b5114610570578063d547741f14610583578063e7dc263b146105a3578063f1be0eba146105b6576101e3565b8063b55d9904146104ee578063c5730e2d1461050e578063ca15c8731461053b578063ce883cdb1461055b576101e3565b8063a217fddf116100d1578063a217fddf14610484578063a7666d4b14610499578063afd5beed146104b9578063b26a5102146104ce576101e3565b8063764f3aa8146103f75780638a754bbe146104175780639010d07c1461042a57806391d1485414610457576101e3565b80633b7d09461161017a5780635b506a00116101495780635b506a001461038d578063656dc2e4146103ad578063676bca21146103cd5780636d2f2246146103e2576101e3565b80633b7d09461461031a578063424c265b1461032d578063450efe21146103405780634ed33ace1461036d576101e3565b8063248a9ca3116101b6578063248a9ca3146102805780632e23cc80146102ad5780632f2ff15d146102da57806336568abe146102fa576101e3565b8063017f2093146101e857806306b6e7771461021e57806313d21cdf146102335780631ed668db14610253575b600080fd5b3480156101f457600080fd5b506102086102033660046134fe565b6105d6565b60405161021591906140ee565b60405180910390f35b61023161022c366004613605565b6107ea565b005b34801561023f57600080fd5b5061020861024e3660046133f2565b610af1565b34801561025f57600080fd5b5061027361026e3660046133f2565b610b5c565b6040516102159190614101565b34801561028c57600080fd5b506102a061029b3660046134fe565b610c08565b6040516102159190613b2f565b3480156102b957600080fd5b506102cd6102c83660046133f2565b610c1d565b6040516102159190613aec565b3480156102e657600080fd5b506102316102f5366004613516565b610fc2565b34801561030657600080fd5b50610231610315366004613516565b61100a565b6102316103283660046133f2565b61104c565b61023161033b3660046133f2565b61113e565b34801561034c57600080fd5b5061036061035b3660046133f2565b611364565b6040516102159190613ad9565b34801561037957600080fd5b506102a06103883660046133f2565b61143c565b34801561039957600080fd5b506102a06103a83660046134fe565b6114e4565b3480156103b957600080fd5b506103606103c83660046133f2565b6114f6565b3480156103d957600080fd5b506102a06115cc565b3480156103ee57600080fd5b506102a06115f0565b34801561040357600080fd5b506102cd6104123660046133f2565b611614565b610231610425366004613605565b611657565b34801561043657600080fd5b5061044a61044536600461353a565b611bc7565b6040516102159190613a78565b34801561046357600080fd5b50610477610472366004613516565b611be8565b6040516102159190613b24565b34801561049057600080fd5b506102a0611c00565b3480156104a557600080fd5b506102086104b43660046134fe565b611c05565b3480156104c557600080fd5b506102a0611e00565b3480156104da57600080fd5b506102a06104e93660046133f2565b611e24565b3480156104fa57600080fd5b506104776105093660046133f2565b611e36565b34801561051a57600080fd5b5061052e61052936600461342a565b611ede565b6040516102159190613a8c565b34801561054757600080fd5b506102a06105563660046134fe565b611f9d565b34801561056757600080fd5b506102a0611fb4565b61023161057e366004613462565b611fba565b34801561058f57600080fd5b5061023161059e366004613516565b61207d565b6102316105b1366004613751565b6120b7565b3480156105c257600080fd5b506102a06105d13660046133f2565b612b3f565b6105de6131e5565b600082815260036020526040902054806106135760405162461bcd60e51b815260040161060a9061405a565b60405180910390fd5b6004600182038154811061062357fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a0860193928301828280156106e957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116106cb575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561074b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161072d575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529150505b919050565b6108147fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6108305760405162461bcd60e51b815260040161060a90613ce8565b80516001600160a01b0316600090815260026020526040902054806108675760405162461bcd60e51b815260040161060a9061405a565b600181039050816004828154811061087b57fe5b6000918252602091829020835160089092020180546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617825584840151600183018054604088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff93871691851691909117929092169190911790556060850151600283015560808501516003830180549190941691161790915560a08301518051919261095a92600485019290910190613248565b5060c08201518051610976916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915582516040519116907f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e90610ae59084908690614158565b60405180910390a25050565b610af96131e5565b6001600160a01b0382166000908152600260205260409020548290610b305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061062357fe5b610b646132c5565b6001600160a01b0382166000908152600260205260409020548290610b9b5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604090205460048054909160001901908110610bc757fe5b906000526020600020906008020160070160169054906101000a900460ff16610bf857610bf383612bc4565b610c01565b610c0183612c6b565b9392505050565b60009081526020819052604090206002015490565b6001600160a01b0381166000908152600260205260409020546060908290610c575760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604081205460048054600019909201929183908110610c8657fe5b60009182526020909120600660089092020101546001600160a01b031690506060610cb082612d14565b9050600060048481548110610cc157fe5b6000918252602082206005600890920201015483516040517f91ceb3eb000000000000000000000000000000000000000000000000000000008152919350830391906001600160a01b038a16906391ceb3eb90610d229085906004016142bc565b60206040518083038186803b158015610d3a57600080fd5b505afa158015610d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7291906137fa565b905060006004600160026000896001600160a01b03166001600160a01b03168152602001908152602001600020540381548110610dab57fe5b600091825260209182902060016008909202010154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b158015610e1557600080fd5b505afa158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4d91906137fa565b90508367ffffffffffffffff81118015610e6657600080fd5b50604051908082528060200260200182016040528015610e90578160200160208202803683370190505b50985060005b838160ff161015610f58576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038c16906391ceb3eb90610ee69084906004016142bc565b60206040518083038186803b158015610efe57600080fd5b505afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3691906137fa565b8a8260ff1681518110610f4557fe5b6020908102919091010152600101610e96565b50825b84811015610fb457610f9582610f8f858988860381518110610f7957fe5b6020026020010151612e6990919063ffffffff16565b90612ea3565b8a8281518110610fa157fe5b6020908102919091010152600101610f5b565b505050505050505050919050565b600082815260208190526040902060020154610fe090610472612ed5565b610ffc5760405162461bcd60e51b815260040161060a90613be6565b6110068282612ed9565b5050565b611012612ed5565b6001600160a01b0316816001600160a01b0316146110425760405162461bcd60e51b815260040161060a90614091565b6110068282612f42565b6110767fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6110925760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806110c85760405162461bcd60e51b815260040161060a9061405a565b6001810390506001600482815481106110dd57fe5b906000526020600020906008020160070160156101000a81548160ff021916908315150217905550816001600160a01b03167ff53dcf4cb920d5a07b1ae3e0756c787bb675805c0176515e9cc6a33226f068b282604051610ae59190613b2f565b6111687fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6111845760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806111ba5760405162461bcd60e51b815260040161060a9061405a565b6000600482815481106111c957fe5b6000918252602090912060089091020180549091506001600160a01b038481169116146112085760405162461bcd60e51b815260040161060a90613cb1565b6007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055604080517f8da5cb5b0000000000000000000000000000000000000000000000000000000081529051611300917f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c26916001600160a01b03871691638da5cb5b916004808301926020929190829003018186803b1580156112c857600080fd5b505afa1580156112dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610472919061340e565b61131c5760405162461bcd60e51b815260040161060a90613c43565b826001600160a01b03167f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e8383604051611357929190614179565b60405180910390a2505050565b6001600160a01b038116600090815260026020526040902054606090829061139e5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b038316600090815260026020526040902054600480549091600019019081106113ca57fe5b906000526020600020906008020160040180548060200260200160405190810160405280929190818152602001828054801561142f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611411575b5050505050915050919050565b6001600160a01b03811660009081526002602052604081205482906114735760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663d46300fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b505afa1580156114c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906137fa565b60036020526000908152604090205481565b6001600160a01b03811660009081526002602052604090205460609082906115305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061155c57fe5b906000526020600020906008020160050180548060200260200160405190810160405280929190818152602001828054801561142f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611411575050505050915050919050565b7fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e81565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6001600160a01b038116600090815260026020526040902054606090829061164e5760405162461bcd60e51b815260040161060a90613fb5565b610c0183612d14565b6116817fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e33611be8565b61169d5760405162461bcd60e51b815260040161060a90613e45565b60005b8160a00151518160ff16101561176f5760005b8160ff168160ff16101561176657600560008460a001518360ff16815181106116d857fe5b60200260200101518560a001518560ff16815181106116f357fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208651815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016116b3565b506001016116a0565b506101008101516001600160a01b0316156118775760005b8160c00151518160ff1610156118755760a0820151516117a8906002612fab565b8160ff16111561186d5760005b60018360a00151510381101561186b57600560008460c0015183815181106117d957fe5b60200260200101518560c001518560ff16815181106117f457fe5b6020908102919091018101516001600160a01b039218821683528281019390935260409091016000908120610100870151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016117b5565b505b600101611787565b505b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a08401518051859492936119fe937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c08201518051611a1a916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055835190519216917f662dd796ff757466e483389dd24bcbb94cb0591dfd6b1972962f5a147b69333191611bbc9160001991909101908590614158565b60405180910390a250565b6000828152602081905260408120611bdf9083612fd3565b90505b92915050565b6000828152602081905260408120611bdf9083612fdf565b600081565b611c0d6131e5565b6004548210611c2e5760405162461bcd60e51b815260040161060a90613ed9565b60048281548110611c3b57fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a086019392830182828015611d0157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ce3575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611d6357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d45575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529050919050565b7f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2681565b60026020526000908152604090205481565b6001600160a01b0381166000908152600260205260408120548290611e6d5760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ea657600080fd5b505afa158015611eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906134e2565b60606001600160a01b03831615801590611f0a5750816001600160a01b0316836001600160a01b031614155b611f265760405162461bcd60e51b815260040161060a90613de8565b6001600160a01b038383181660009081526005602090815260409182902080548351818402810184019094528084529091830182828015611f9057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f72575b5050505050905092915050565b6000818152602081905260408120611be290612ff4565b60045490565b60005b82811015612077576000606030868685818110611fd657fe5b9050602002810190611fe891906142ca565b604051611ff6929190613a68565b600060405180830381855af49150503d8060008114612031576040519150601f19603f3d011682016040523d82523d6000602084013e612036565b606091505b5091509150811580156120465750835b1561206d5761205481612fff565b60405162461bcd60e51b815260040161060a9190613b38565b5050600101611fbd565b50505050565b60008281526020819052604090206002015461209b90610472612ed5565b6110425760405162461bcd60e51b815260040161060a90613d8b565b600260015414156120da5760405162461bcd60e51b815260040161060a90614023565b60026001556121097fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6121255760405162461bcd60e51b815260040161060a90613e45565b80516001600160a01b031661214c5760405162461bcd60e51b815260040161060a90613f10565b80516001600160a01b0316600090815260026020526040902054156121835760405162461bcd60e51b815260040161060a90613fec565b6040805160088082526101208201909252606091602082016101008036833750506040805160088082526101208201909252929350606092915060208201610100803683370190505090506121d66131e5565b60405180610180016040528085600001516001600160a01b0316815260200160006001600160a01b03168152602001856020015160ff1681526020018560400151815260200185606001516001600160a01b0316815260200184815260200183815260200160006001600160a01b0316815260200185608001516001600160a01b031681526020018560a00151151581526020018560c00151151581526020018560e00151151581525090508360e0015161229f57835161229690612bc4565b60c001516122af565b83516122aa90612c6b565b60c001515b6001600160a01b0316602082015260005b60088160ff16101561249a5784516040517f82b866000000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906382b86600906123149084906004016142bc565b60206040518083038186803b15801561232c57600080fd5b505afa92505050801561237a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526123779181019061340e565b60015b61238c5780600803845103845261249a565b6001600160a01b0381166123b25760405162461bcd60e51b815260040161060a90613f7e565b80858360ff16815181106123c257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060005b8260ff168160ff1610156124905760056000878360ff168151811061240657fe5b6020026020010151888660ff168151811061241d57fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208a51815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016123e5565b50506001016122c0565b5060808401516001600160a01b0316156127e05783608001516001600160a01b0316639750a8ee6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124eb57600080fd5b505afa1580156124ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612523919061340e565b6001600160a01b031660e0820181905260009081526002602052604090205461255e5760405162461bcd60e51b815260040161060a90613c7a565b60005b60088160ff1610156127315784608001516001600160a01b03166382b86600826040518263ffffffff1660e01b815260040161259d91906142bc565b60206040518083038186803b1580156125b557600080fd5b505afa925050508015612603575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526126009181019061340e565b60015b61261557806008038351038352612731565b6001600160a01b03811661263b5760405162461bcd60e51b815260040161060a90613f7e565b80848360ff168151811061264b57fe5b6001600160a01b03909216602092830291909101909101528451612670906002612fab565b8260ff1611156127285760005b6001865103811015612726576005600086838151811061269957fe5b6020026020010151878660ff16815181106126b057fe5b6020908102919091018101516001600160a01b03921882168352828101939093526040909101600090812060808b0151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790550161267d565b505b50600101612561565b5083600001516001600160a01b031684608001516001600160a01b031663cb2ef5fe6040518163ffffffff1660e01b815260040160206040518083038186803b15801561277d57600080fd5b505afa158015612791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b5919061340e565b6001600160a01b0316146127db5760405162461bcd60e51b815260040161060a90613f47565b6127e8565b600882510382525b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a084015180518594929361296f937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c0820151805161298b916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055865190519216917f15ec4115f45227a2f5b970962fd2294c7be9ba12b0652daae49ff679c02a1e0291612b2d9160001991909101908590614158565b60405180910390a25050600180555050565b6001600160a01b0381166000908152600260205260408120548290612b765760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663e25aa5fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b6000611bdf836001600160a01b03841661305f565b612bcc6132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612c0557600080fd5b505afa158015612c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c3d9190613812565b6001600160a01b031660c088015260a087015260808601526060850152604084015260208301528152919050565b612c736132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612cad57600080fd5b505afa158015612cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce59190613871565b6001600160a01b031660c08901525060a087015260808601526060850152604084015260208301528152919050565b6001600160a01b038116600090815260026020526040812054600480546060939260001901908110612d4257fe5b90600052602060002090600802016004018054905090508067ffffffffffffffff81118015612d7057600080fd5b50604051908082528060200260200182016040528015612d9a578160200160208202803683370190505b50915060005b818160ff161015612e62576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038516906391ceb3eb90612df09084906004016142bc565b60206040518083038186803b158015612e0857600080fd5b505afa158015612e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4091906137fa565b838260ff1681518110612e4f57fe5b6020908102919091010152600101612da0565b5050919050565b600082612e7857506000611be2565b82820282848281612e8557fe5b0414611bdf5760405162461bcd60e51b815260040161060a90613e7c565b6000808211612ec45760405162461bcd60e51b815260040161060a90613d54565b818381612ecd57fe5b049392505050565b3390565b6000828152602081905260409020612ef19082612baf565b1561100657612efe612ed5565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081905260409020612f5a90826130a9565b1561100657612f67612ed5565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600082821115612fcd5760405162461bcd60e51b815260040161060a90613d1d565b50900390565b6000611bdf83836130be565b6000611bdf836001600160a01b038416613103565b6000611be28261311b565b6060604482511015613045575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c7900000060208201526107e5565b60048201915081806020019051810190611be2919061355b565b600061306b8383613103565b6130a157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611be2565b506000611be2565b6000611bdf836001600160a01b03841661311f565b815460009082106130e15760405162461bcd60e51b815260040161060a90613b89565b8260000182815481106130f057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156131db578354600019808301919081019060009087908390811061315257fe5b906000526020600020015490508087600001848154811061316f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061319f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611be2565b6000915050611be2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8280548282559060005260206000209081019282156132b5579160200282015b828111156132b557825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613268565b506132c192915061330b565b5090565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b5b808211156132c15780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161330c565b8035611be281614393565b600082601f83011261335d578081fd5b813567ffffffffffffffff811115613373578182fd5b6020808202613383828201614334565b8381529350818401858301828701840188101561339f57600080fd5b600092505b848310156133cb5780356133b781614393565b8252600192909201919083019083016133a4565b505050505092915050565b8035611be2816143ab565b803560ff81168114611be257600080fd5b600060208284031215613403578081fd5b8135611bdf81614393565b60006020828403121561341f578081fd5b8151611bdf81614393565b6000806040838503121561343c578081fd5b823561344781614393565b9150602083013561345781614393565b809150509250929050565b600080600060408486031215613476578081fd5b833567ffffffffffffffff8082111561348d578283fd5b818601915086601f8301126134a0578283fd5b8135818111156134ae578384fd5b87602080830285010111156134c1578384fd5b602092830195509350508401356134d7816143ab565b809150509250925092565b6000602082840312156134f3578081fd5b8151611bdf816143ab565b60006020828403121561350f578081fd5b5035919050565b60008060408385031215613528578182fd5b82359150602083013561345781614393565b6000806040838503121561354c578182fd5b50508035926020909101359150565b60006020828403121561356c578081fd5b815167ffffffffffffffff80821115613583578283fd5b818401915084601f830112613596578283fd5b8151818111156135a4578384fd5b6135d560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614334565b91508082528560208285010111156135eb578384fd5b6135fc816020840160208601614367565b50949350505050565b600060208284031215613616578081fd5b813567ffffffffffffffff8082111561362d578283fd5b8184019150610180808387031215613643578384fd5b61364c81614334565b90506136588684613342565b81526136678660208501613342565b602082015261367986604085016133e1565b6040820152606083013560608201526136958660808501613342565b608082015260a0830135828111156136ab578485fd5b6136b78782860161334d565b60a08301525060c0830135828111156136ce578485fd5b6136da8782860161334d565b60c0830152506136ed8660e08501613342565b60e0820152610100915061370386838501613342565b828201526101209150613718868385016133d6565b82820152610140915061372d868385016133d6565b828201526101609150613742868385016133d6565b91810191909152949350505050565b6000610100808385031215613764578182fd5b61376d81614334565b9050823561377a81614393565b815261378984602085016133e1565b60208201526040830135604082015260608301356137a681614393565b60608201526137b88460808501613342565b60808201526137ca8460a085016133d6565b60a08201526137dc8460c085016133d6565b60c08201526137ee8460e085016133d6565b60e08201529392505050565b60006020828403121561380b578081fd5b5051919050565b600080600080600080600060e0888a03121561382c578485fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c088015161386181614393565b8091505092959891949750929550565b600080600080600080600080610100898b03121561388d578182fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c0890151915060e08901516138c981614393565b809150509295985092959890939650565b6001600160a01b03169052565b6000815180845260208085019450808401835b8381101561391f5781516001600160a01b0316875295820195908201906001016138fa565b509495945050505050565b6000815480845260208085019450838352808320835b8381101561391f5781546001600160a01b031687529582019560019182019101613940565b15159052565b600061018061397b8484516138da565b602083015161398d60208601826138da565b5060408301516139a06040860182613a61565b506060830151606085015260808301516139bd60808601826138da565b5060a08301518160a08601526139d5828601826138e7565b91505060c083015184820360c08601526139ef82826138e7565b91505060e0830151613a0460e08601826138da565b5061010080840151613a18828701826138da565b505061012080840151613a2d82870182613965565b505061014080840151613a4282870182613965565b505061016080840151613a5782870182613965565b5090949350505050565b60ff169052565b6000828483379101908152919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015613acd5783516001600160a01b031683529284019291840191600101613aa8565b50909695505050505050565b600060208252611bdf60208301846138e7565b6020808252825182820181905260009190848201906040850190845b81811015613acd57835183529284019291840191600101613b08565b901515815260200190565b90815260200190565b6000602082528251806020840152613b57816040850160208701614367565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601b908201527f506f6f6c206973206e6f74206f776e656420627920736164646c650000000000604082015260600190565b60208082526017908201527f50523a206261736520706f6f6c206e6f7420666f756e64000000000000000000604082015260600190565b60208082526018908201527f50523a20706f6f6c41646472657373206d69736d617463680000000000000000604082015260600190565b6020808252818101527f50523a2043616c6c6572206973206e6f7420736164646c65206d616e61676572604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252602a908201527f50523a2066726f6d20616e6420746f2063616e6e6f7420626520746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f50523a204f6e6c79206d616e61676572732063616e2061646420706f6f6c7300604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f50523a20496e646578206f7574206f6620626f756e6473000000000000000000604082015260600190565b60208082526014908201527f50523a20706f6f6c416464726573732069732030000000000000000000000000604082015260600190565b6020808252601d908201527f50523a206d657461537761702061646472657373206d69736d61746368000000604082015260600190565b6020808252600e908201527f50523a20746f6b656e2069732030000000000000000000000000000000000000604082015260600190565b6020808252601a908201527f50523a204e6f206d61746368696e6720706f6f6c20666f756e64000000000000604082015260600190565b60208082526019908201527f50523a20506f6f6c20697320616c726561647920616464656400000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526012908201527f50523a20506f6f6c206e6f7420666f756e640000000000000000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252611bdf602083018461396b565b600060e082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a08301526001600160a01b0360c08401511660c083015292915050565b600083825260406020830152614171604083018461396b565b949350505050565b60008382526040602083015261419b60408301614196855461435b565b6138da565b60018301546001600160a01b036141b7606085018284166138da565b6141ca6080850160ff8460a01c16613a61565b600285015460a08501526141e1600386015461435b565b91506141f060c08501836138da565b61018091508160e085015261420c6101c085016004870161392a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc085820301610100860152614244816005880161392a565b9050614253600687015461435b565b6142616101208701826138da565b50600786015461427761014087018483166138da565b61428b610160870160ff8360a01c16613965565b61429d84870160ff8360a81c16613965565b6142b16101a0870160ff8360b01c16613965565b509695505050505050565b60ff91909116815260200190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126142fe578283fd5b83018035915067ffffffffffffffff821115614318578283fd5b60200191503681900382131561432d57600080fd5b9250929050565b60405181810167ffffffffffffffff8111828210171561435357600080fd5b604052919050565b6001600160a01b031690565b60005b8381101561438257818101518382015260200161436a565b838111156120775750506000910152565b6001600160a01b03811681146143a857600080fd5b50565b80151581146143a857600080fdfea2646970667358221220a266f2059da4f79d97801839fac0cb1e0da563f8e29fe4821993975c7bd4773e64736f6c634300060c0033", + "deployedBytecode": "0x6080604052600436106101e35760003560e01c8063764f3aa811610102578063b55d990411610095578063d2423b5111610064578063d2423b5114610570578063d547741f14610583578063e7dc263b146105a3578063f1be0eba146105b6576101e3565b8063b55d9904146104ee578063c5730e2d1461050e578063ca15c8731461053b578063ce883cdb1461055b576101e3565b8063a217fddf116100d1578063a217fddf14610484578063a7666d4b14610499578063afd5beed146104b9578063b26a5102146104ce576101e3565b8063764f3aa8146103f75780638a754bbe146104175780639010d07c1461042a57806391d1485414610457576101e3565b80633b7d09461161017a5780635b506a00116101495780635b506a001461038d578063656dc2e4146103ad578063676bca21146103cd5780636d2f2246146103e2576101e3565b80633b7d09461461031a578063424c265b1461032d578063450efe21146103405780634ed33ace1461036d576101e3565b8063248a9ca3116101b6578063248a9ca3146102805780632e23cc80146102ad5780632f2ff15d146102da57806336568abe146102fa576101e3565b8063017f2093146101e857806306b6e7771461021e57806313d21cdf146102335780631ed668db14610253575b600080fd5b3480156101f457600080fd5b506102086102033660046134fe565b6105d6565b60405161021591906140ee565b60405180910390f35b61023161022c366004613605565b6107ea565b005b34801561023f57600080fd5b5061020861024e3660046133f2565b610af1565b34801561025f57600080fd5b5061027361026e3660046133f2565b610b5c565b6040516102159190614101565b34801561028c57600080fd5b506102a061029b3660046134fe565b610c08565b6040516102159190613b2f565b3480156102b957600080fd5b506102cd6102c83660046133f2565b610c1d565b6040516102159190613aec565b3480156102e657600080fd5b506102316102f5366004613516565b610fc2565b34801561030657600080fd5b50610231610315366004613516565b61100a565b6102316103283660046133f2565b61104c565b61023161033b3660046133f2565b61113e565b34801561034c57600080fd5b5061036061035b3660046133f2565b611364565b6040516102159190613ad9565b34801561037957600080fd5b506102a06103883660046133f2565b61143c565b34801561039957600080fd5b506102a06103a83660046134fe565b6114e4565b3480156103b957600080fd5b506103606103c83660046133f2565b6114f6565b3480156103d957600080fd5b506102a06115cc565b3480156103ee57600080fd5b506102a06115f0565b34801561040357600080fd5b506102cd6104123660046133f2565b611614565b610231610425366004613605565b611657565b34801561043657600080fd5b5061044a61044536600461353a565b611bc7565b6040516102159190613a78565b34801561046357600080fd5b50610477610472366004613516565b611be8565b6040516102159190613b24565b34801561049057600080fd5b506102a0611c00565b3480156104a557600080fd5b506102086104b43660046134fe565b611c05565b3480156104c557600080fd5b506102a0611e00565b3480156104da57600080fd5b506102a06104e93660046133f2565b611e24565b3480156104fa57600080fd5b506104776105093660046133f2565b611e36565b34801561051a57600080fd5b5061052e61052936600461342a565b611ede565b6040516102159190613a8c565b34801561054757600080fd5b506102a06105563660046134fe565b611f9d565b34801561056757600080fd5b506102a0611fb4565b61023161057e366004613462565b611fba565b34801561058f57600080fd5b5061023161059e366004613516565b61207d565b6102316105b1366004613751565b6120b7565b3480156105c257600080fd5b506102a06105d13660046133f2565b612b3f565b6105de6131e5565b600082815260036020526040902054806106135760405162461bcd60e51b815260040161060a9061405a565b60405180910390fd5b6004600182038154811061062357fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a0860193928301828280156106e957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116106cb575b505050505081526020016005820180548060200260200160405190810160405280929190818152602001828054801561074b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161072d575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529150505b919050565b6108147fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6108305760405162461bcd60e51b815260040161060a90613ce8565b80516001600160a01b0316600090815260026020526040902054806108675760405162461bcd60e51b815260040161060a9061405a565b600181039050816004828154811061087b57fe5b6000918252602091829020835160089092020180546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617825584840151600183018054604088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff93871691851691909117929092169190911790556060850151600283015560808501516003830180549190941691161790915560a08301518051919261095a92600485019290910190613248565b5060c08201518051610976916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915582516040519116907f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e90610ae59084908690614158565b60405180910390a25050565b610af96131e5565b6001600160a01b0382166000908152600260205260409020548290610b305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061062357fe5b610b646132c5565b6001600160a01b0382166000908152600260205260409020548290610b9b5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604090205460048054909160001901908110610bc757fe5b906000526020600020906008020160070160169054906101000a900460ff16610bf857610bf383612bc4565b610c01565b610c0183612c6b565b9392505050565b60009081526020819052604090206002015490565b6001600160a01b0381166000908152600260205260409020546060908290610c575760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b03831660009081526002602052604081205460048054600019909201929183908110610c8657fe5b60009182526020909120600660089092020101546001600160a01b031690506060610cb082612d14565b9050600060048481548110610cc157fe5b6000918252602082206005600890920201015483516040517f91ceb3eb000000000000000000000000000000000000000000000000000000008152919350830391906001600160a01b038a16906391ceb3eb90610d229085906004016142bc565b60206040518083038186803b158015610d3a57600080fd5b505afa158015610d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7291906137fa565b905060006004600160026000896001600160a01b03166001600160a01b03168152602001908152602001600020540381548110610dab57fe5b600091825260209182902060016008909202010154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b158015610e1557600080fd5b505afa158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4d91906137fa565b90508367ffffffffffffffff81118015610e6657600080fd5b50604051908082528060200260200182016040528015610e90578160200160208202803683370190505b50985060005b838160ff161015610f58576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038c16906391ceb3eb90610ee69084906004016142bc565b60206040518083038186803b158015610efe57600080fd5b505afa158015610f12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3691906137fa565b8a8260ff1681518110610f4557fe5b6020908102919091010152600101610e96565b50825b84811015610fb457610f9582610f8f858988860381518110610f7957fe5b6020026020010151612e6990919063ffffffff16565b90612ea3565b8a8281518110610fa157fe5b6020908102919091010152600101610f5b565b505050505050505050919050565b600082815260208190526040902060020154610fe090610472612ed5565b610ffc5760405162461bcd60e51b815260040161060a90613be6565b6110068282612ed9565b5050565b611012612ed5565b6001600160a01b0316816001600160a01b0316146110425760405162461bcd60e51b815260040161060a90614091565b6110068282612f42565b6110767fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6110925760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806110c85760405162461bcd60e51b815260040161060a9061405a565b6001810390506001600482815481106110dd57fe5b906000526020600020906008020160070160156101000a81548160ff021916908315150217905550816001600160a01b03167ff53dcf4cb920d5a07b1ae3e0756c787bb675805c0176515e9cc6a33226f068b282604051610ae59190613b2f565b6111687fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6111845760405162461bcd60e51b815260040161060a90613ce8565b6001600160a01b038116600090815260026020526040902054806111ba5760405162461bcd60e51b815260040161060a9061405a565b6000600482815481106111c957fe5b6000918252602090912060089091020180549091506001600160a01b038481169116146112085760405162461bcd60e51b815260040161060a90613cb1565b6007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055604080517f8da5cb5b0000000000000000000000000000000000000000000000000000000081529051611300917f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c26916001600160a01b03871691638da5cb5b916004808301926020929190829003018186803b1580156112c857600080fd5b505afa1580156112dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610472919061340e565b61131c5760405162461bcd60e51b815260040161060a90613c43565b826001600160a01b03167f21292cd2979873e2f844b8d081ebe90c5d4095362e2814ea54332ec7b6fd432e8383604051611357929190614179565b60405180910390a2505050565b6001600160a01b038116600090815260026020526040902054606090829061139e5760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b038316600090815260026020526040902054600480549091600019019081106113ca57fe5b906000526020600020906008020160040180548060200260200160405190810160405280929190818152602001828054801561142f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611411575b5050505050915050919050565b6001600160a01b03811660009081526002602052604081205482906114735760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663d46300fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b505afa1580156114c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906137fa565b60036020526000908152604090205481565b6001600160a01b03811660009081526002602052604090205460609082906115305760405162461bcd60e51b815260040161060a90613fb5565b6001600160a01b0383166000908152600260205260409020546004805490916000190190811061155c57fe5b906000526020600020906008020160050180548060200260200160405190810160405280929190818152602001828054801561142f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611411575050505050915050919050565b7fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e81565b7fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd81565b6001600160a01b038116600090815260026020526040902054606090829061164e5760405162461bcd60e51b815260040161060a90613fb5565b610c0183612d14565b6116817fa9eb1bd0b8bd5d75005d4e3c25736746c884daef9ecff243b81b4cc73cfb7f9e33611be8565b61169d5760405162461bcd60e51b815260040161060a90613e45565b60005b8160a00151518160ff16101561176f5760005b8160ff168160ff16101561176657600560008460a001518360ff16815181106116d857fe5b60200260200101518560a001518560ff16815181106116f357fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208651815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016116b3565b506001016116a0565b506101008101516001600160a01b0316156118775760005b8160c00151518160ff1610156118755760a0820151516117a8906002612fab565b8160ff16111561186d5760005b60018360a00151510381101561186b57600560008460c0015183815181106117d957fe5b60200260200101518560c001518560ff16815181106117f457fe5b6020908102919091018101516001600160a01b039218821683528281019390935260409091016000908120610100870151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016117b5565b505b600101611787565b505b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a08401518051859492936119fe937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c08201518051611a1a916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055835190519216917f662dd796ff757466e483389dd24bcbb94cb0591dfd6b1972962f5a147b69333191611bbc9160001991909101908590614158565b60405180910390a250565b6000828152602081905260408120611bdf9083612fd3565b90505b92915050565b6000828152602081905260408120611bdf9083612fdf565b600081565b611c0d6131e5565b6004548210611c2e5760405162461bcd60e51b815260040161060a90613ed9565b60048281548110611c3b57fe5b60009182526020918290206040805161018081018252600890930290910180546001600160a01b03908116845260018201548082168587015260ff7401000000000000000000000000000000000000000090910416848401526002820154606085015260038201541660808401526004810180548351818702810187019094528084529394919360a086019392830182828015611d0157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611ce3575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611d6357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d45575b505050918352505060068201546001600160a01b039081166020830152600790920154918216604082015260ff74010000000000000000000000000000000000000000830481161515606083015275010000000000000000000000000000000000000000008304811615156080830152760100000000000000000000000000000000000000000000909204909116151560a0909101529050919050565b7f3a8f22a562b0a1c1adc8307ab58a0c1a080aee6a8195ccea22d34ff640461c2681565b60026020526000908152604090205481565b6001600160a01b0381166000908152600260205260408120548290611e6d5760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ea657600080fd5b505afa158015611eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0191906134e2565b60606001600160a01b03831615801590611f0a5750816001600160a01b0316836001600160a01b031614155b611f265760405162461bcd60e51b815260040161060a90613de8565b6001600160a01b038383181660009081526005602090815260409182902080548351818402810184019094528084529091830182828015611f9057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f72575b5050505050905092915050565b6000818152602081905260408120611be290612ff4565b60045490565b60005b82811015612077576000606030868685818110611fd657fe5b9050602002810190611fe891906142ca565b604051611ff6929190613a68565b600060405180830381855af49150503d8060008114612031576040519150601f19603f3d011682016040523d82523d6000602084013e612036565b606091505b5091509150811580156120465750835b1561206d5761205481612fff565b60405162461bcd60e51b815260040161060a9190613b38565b5050600101611fbd565b50505050565b60008281526020819052604090206002015461209b90610472612ed5565b6110425760405162461bcd60e51b815260040161060a90613d8b565b600260015414156120da5760405162461bcd60e51b815260040161060a90614023565b60026001556121097fe132a6a517694e2454dc663f0d4fa738f94e7c1bd06c8950d14f9db8832494bd33611be8565b6121255760405162461bcd60e51b815260040161060a90613e45565b80516001600160a01b031661214c5760405162461bcd60e51b815260040161060a90613f10565b80516001600160a01b0316600090815260026020526040902054156121835760405162461bcd60e51b815260040161060a90613fec565b6040805160088082526101208201909252606091602082016101008036833750506040805160088082526101208201909252929350606092915060208201610100803683370190505090506121d66131e5565b60405180610180016040528085600001516001600160a01b0316815260200160006001600160a01b03168152602001856020015160ff1681526020018560400151815260200185606001516001600160a01b0316815260200184815260200183815260200160006001600160a01b0316815260200185608001516001600160a01b031681526020018560a00151151581526020018560c00151151581526020018560e00151151581525090508360e0015161229f57835161229690612bc4565b60c001516122af565b83516122aa90612c6b565b60c001515b6001600160a01b0316602082015260005b60088160ff16101561249a5784516040517f82b866000000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906382b86600906123149084906004016142bc565b60206040518083038186803b15801561232c57600080fd5b505afa92505050801561237a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526123779181019061340e565b60015b61238c5780600803845103845261249a565b6001600160a01b0381166123b25760405162461bcd60e51b815260040161060a90613f7e565b80858360ff16815181106123c257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060005b8260ff168160ff1610156124905760056000878360ff168151811061240657fe5b6020026020010151888660ff168151811061241d57fe5b6020908102919091018101516001600160a01b0392188216835282810193909352604090910160009081208a51815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055016123e5565b50506001016122c0565b5060808401516001600160a01b0316156127e05783608001516001600160a01b0316639750a8ee6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124eb57600080fd5b505afa1580156124ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612523919061340e565b6001600160a01b031660e0820181905260009081526002602052604090205461255e5760405162461bcd60e51b815260040161060a90613c7a565b60005b60088160ff1610156127315784608001516001600160a01b03166382b86600826040518263ffffffff1660e01b815260040161259d91906142bc565b60206040518083038186803b1580156125b557600080fd5b505afa925050508015612603575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526126009181019061340e565b60015b61261557806008038351038352612731565b6001600160a01b03811661263b5760405162461bcd60e51b815260040161060a90613f7e565b80848360ff168151811061264b57fe5b6001600160a01b03909216602092830291909101909101528451612670906002612fab565b8260ff1611156127285760005b6001865103811015612726576005600086838151811061269957fe5b6020026020010151878660ff16815181106126b057fe5b6020908102919091018101516001600160a01b03921882168352828101939093526040909101600090812060808b0151815460018181018455928452949092209093018054919092167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790550161267d565b505b50600101612561565b5083600001516001600160a01b031684608001516001600160a01b031663cb2ef5fe6040518163ffffffff1660e01b815260040160206040518083038186803b15801561277d57600080fd5b505afa158015612791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b5919061340e565b6001600160a01b0316146127db5760405162461bcd60e51b815260040161060a90613f47565b6127e8565b600882510382525b6004805460018101825560009190915281517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b600890920291820180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b039384161782556020808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c860180546040890151908516928716929092177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000060ff9093169290920291909117905560608601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d86015560808601517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e86018054909316941693909317905560a084015180518594929361296f937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19f01920190613248565b5060c0820151805161298b916005840191602090910190613248565b5060e08201516006820180546001600160a01b039283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915561010084015160079093018054610120860151610140870151610160909701511515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff9715157501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff92151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff988816949096169390931796909616939093179290921691909117939093169190911790915560045482518216600090815260026020908152604080832084905560608601518352600390915290819020829055865190519216917f15ec4115f45227a2f5b970962fd2294c7be9ba12b0652daae49ff679c02a1e0291612b2d9160001991909101908590614158565b60405180910390a25050600180555050565b6001600160a01b0381166000908152600260205260408120548290612b765760405162461bcd60e51b815260040161060a90613fb5565b826001600160a01b031663e25aa5fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114ac57600080fd5b6000611bdf836001600160a01b03841661305f565b612bcc6132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612c0557600080fd5b505afa158015612c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c3d9190613812565b6001600160a01b031660c088015260a087015260808601526060850152604084015260208301528152919050565b612c736132c5565b816001600160a01b0316635fd65f0f6040518163ffffffff1660e01b81526004016101006040518083038186803b158015612cad57600080fd5b505afa158015612cc1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce59190613871565b6001600160a01b031660c08901525060a087015260808601526060850152604084015260208301528152919050565b6001600160a01b038116600090815260026020526040812054600480546060939260001901908110612d4257fe5b90600052602060002090600802016004018054905090508067ffffffffffffffff81118015612d7057600080fd5b50604051908082528060200260200182016040528015612d9a578160200160208202803683370190505b50915060005b818160ff161015612e62576040517f91ceb3eb0000000000000000000000000000000000000000000000000000000081526001600160a01b038516906391ceb3eb90612df09084906004016142bc565b60206040518083038186803b158015612e0857600080fd5b505afa158015612e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4091906137fa565b838260ff1681518110612e4f57fe5b6020908102919091010152600101612da0565b5050919050565b600082612e7857506000611be2565b82820282848281612e8557fe5b0414611bdf5760405162461bcd60e51b815260040161060a90613e7c565b6000808211612ec45760405162461bcd60e51b815260040161060a90613d54565b818381612ecd57fe5b049392505050565b3390565b6000828152602081905260409020612ef19082612baf565b1561100657612efe612ed5565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081905260409020612f5a90826130a9565b1561100657612f67612ed5565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600082821115612fcd5760405162461bcd60e51b815260040161060a90613d1d565b50900390565b6000611bdf83836130be565b6000611bdf836001600160a01b038416613103565b6000611be28261311b565b6060604482511015613045575060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c7900000060208201526107e5565b60048201915081806020019051810190611be2919061355b565b600061306b8383613103565b6130a157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611be2565b506000611be2565b6000611bdf836001600160a01b03841661311f565b815460009082106130e15760405162461bcd60e51b815260040161060a90613b89565b8260000182815481106130f057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b600081815260018301602052604081205480156131db578354600019808301919081019060009087908390811061315257fe5b906000526020600020015490508087600001848154811061316f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061319f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611be2565b6000915050611be2565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a0820181905260c082015260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b8280548282559060005260206000209081019282156132b5579160200282015b828111156132b557825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190613268565b506132c192915061330b565b5090565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b5b808211156132c15780547fffffffffffffffffffffffff000000000000000000000000000000000000000016815560010161330c565b8035611be281614393565b600082601f83011261335d578081fd5b813567ffffffffffffffff811115613373578182fd5b6020808202613383828201614334565b8381529350818401858301828701840188101561339f57600080fd5b600092505b848310156133cb5780356133b781614393565b8252600192909201919083019083016133a4565b505050505092915050565b8035611be2816143ab565b803560ff81168114611be257600080fd5b600060208284031215613403578081fd5b8135611bdf81614393565b60006020828403121561341f578081fd5b8151611bdf81614393565b6000806040838503121561343c578081fd5b823561344781614393565b9150602083013561345781614393565b809150509250929050565b600080600060408486031215613476578081fd5b833567ffffffffffffffff8082111561348d578283fd5b818601915086601f8301126134a0578283fd5b8135818111156134ae578384fd5b87602080830285010111156134c1578384fd5b602092830195509350508401356134d7816143ab565b809150509250925092565b6000602082840312156134f3578081fd5b8151611bdf816143ab565b60006020828403121561350f578081fd5b5035919050565b60008060408385031215613528578182fd5b82359150602083013561345781614393565b6000806040838503121561354c578182fd5b50508035926020909101359150565b60006020828403121561356c578081fd5b815167ffffffffffffffff80821115613583578283fd5b818401915084601f830112613596578283fd5b8151818111156135a4578384fd5b6135d560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614334565b91508082528560208285010111156135eb578384fd5b6135fc816020840160208601614367565b50949350505050565b600060208284031215613616578081fd5b813567ffffffffffffffff8082111561362d578283fd5b8184019150610180808387031215613643578384fd5b61364c81614334565b90506136588684613342565b81526136678660208501613342565b602082015261367986604085016133e1565b6040820152606083013560608201526136958660808501613342565b608082015260a0830135828111156136ab578485fd5b6136b78782860161334d565b60a08301525060c0830135828111156136ce578485fd5b6136da8782860161334d565b60c0830152506136ed8660e08501613342565b60e0820152610100915061370386838501613342565b828201526101209150613718868385016133d6565b82820152610140915061372d868385016133d6565b828201526101609150613742868385016133d6565b91810191909152949350505050565b6000610100808385031215613764578182fd5b61376d81614334565b9050823561377a81614393565b815261378984602085016133e1565b60208201526040830135604082015260608301356137a681614393565b60608201526137b88460808501613342565b60808201526137ca8460a085016133d6565b60a08201526137dc8460c085016133d6565b60c08201526137ee8460e085016133d6565b60e08201529392505050565b60006020828403121561380b578081fd5b5051919050565b600080600080600080600060e0888a03121561382c578485fd5b875196506020880151955060408801519450606088015193506080880151925060a0880151915060c088015161386181614393565b8091505092959891949750929550565b600080600080600080600080610100898b03121561388d578182fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c0890151915060e08901516138c981614393565b809150509295985092959890939650565b6001600160a01b03169052565b6000815180845260208085019450808401835b8381101561391f5781516001600160a01b0316875295820195908201906001016138fa565b509495945050505050565b6000815480845260208085019450838352808320835b8381101561391f5781546001600160a01b031687529582019560019182019101613940565b15159052565b600061018061397b8484516138da565b602083015161398d60208601826138da565b5060408301516139a06040860182613a61565b506060830151606085015260808301516139bd60808601826138da565b5060a08301518160a08601526139d5828601826138e7565b91505060c083015184820360c08601526139ef82826138e7565b91505060e0830151613a0460e08601826138da565b5061010080840151613a18828701826138da565b505061012080840151613a2d82870182613965565b505061014080840151613a4282870182613965565b505061016080840151613a5782870182613965565b5090949350505050565b60ff169052565b6000828483379101908152919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015613acd5783516001600160a01b031683529284019291840191600101613aa8565b50909695505050505050565b600060208252611bdf60208301846138e7565b6020808252825182820181905260009190848201906040850190845b81811015613acd57835183529284019291840191600101613b08565b901515815260200190565b90815260200190565b6000602082528251806020840152613b57816040850160208701614367565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252601b908201527f506f6f6c206973206e6f74206f776e656420627920736164646c650000000000604082015260600190565b60208082526017908201527f50523a206261736520706f6f6c206e6f7420666f756e64000000000000000000604082015260600190565b60208082526018908201527f50523a20706f6f6c41646472657373206d69736d617463680000000000000000604082015260600190565b6020808252818101527f50523a2043616c6c6572206973206e6f7420736164646c65206d616e61676572604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252602a908201527f50523a2066726f6d20616e6420746f2063616e6e6f7420626520746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f50523a204f6e6c79206d616e61676572732063616e2061646420706f6f6c7300604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f50523a20496e646578206f7574206f6620626f756e6473000000000000000000604082015260600190565b60208082526014908201527f50523a20706f6f6c416464726573732069732030000000000000000000000000604082015260600190565b6020808252601d908201527f50523a206d657461537761702061646472657373206d69736d61746368000000604082015260600190565b6020808252600e908201527f50523a20746f6b656e2069732030000000000000000000000000000000000000604082015260600190565b6020808252601a908201527f50523a204e6f206d61746368696e6720706f6f6c20666f756e64000000000000604082015260600190565b60208082526019908201527f50523a20506f6f6c20697320616c726561647920616464656400000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526012908201527f50523a20506f6f6c206e6f7420666f756e640000000000000000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b600060208252611bdf602083018461396b565b600060e082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a08301526001600160a01b0360c08401511660c083015292915050565b600083825260406020830152614171604083018461396b565b949350505050565b60008382526040602083015261419b60408301614196855461435b565b6138da565b60018301546001600160a01b036141b7606085018284166138da565b6141ca6080850160ff8460a01c16613a61565b600285015460a08501526141e1600386015461435b565b91506141f060c08501836138da565b61018091508160e085015261420c6101c085016004870161392a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc085820301610100860152614244816005880161392a565b9050614253600687015461435b565b6142616101208701826138da565b50600786015461427761014087018483166138da565b61428b610160870160ff8360a01c16613965565b61429d84870160ff8360a81c16613965565b6142b16101a0870160ff8360b01c16613965565b509695505050505050565b60ff91909116815260200190565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126142fe578283fd5b83018035915067ffffffffffffffff821115614318578283fd5b60200191503681900382131561432d57600080fd5b9250929050565b60405181810167ffffffffffffffff8111828210171561435357600080fd5b604052919050565b6001600160a01b031690565b60005b8381101561438257818101518382015260200161436a565b838111156120775750506000910152565b6001600160a01b03811681146143a857600080fd5b50565b80151581146143a857600080fdfea2646970667358221220a266f2059da4f79d97801839fac0cb1e0da563f8e29fe4821993975c7bd4773e64736f6c634300060c0033", + "devdoc": { + "events": { + "AddCommunityPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "params": { + "index": "index of the added pool in the pools list", + "poolAddress": "address of the added pool", + "poolData": "added pool data" + } + }, + "AddPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "params": { + "index": "index of the added pool in the pools list", + "poolAddress": "address of the added pool", + "poolData": "added pool data" + } + }, + "RemovePool(address,uint256)": { + "params": { + "index": "index of the removed pool in the pools list", + "poolAddress": "address of the removed pool" + } + }, + "UpdatePool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "params": { + "index": "index of the updated pool in the pools list", + "poolAddress": "address of the updated pool", + "poolData": "updated pool data" + } + } + }, + "kind": "dev", + "methods": { + "addCommunityPool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "details": "Before adding a meta pool, the user must first add the underlying base pool. Only Swap and MetaSwap contracts need to be added.", + "params": { + "data": "PoolInputData struct for the new pool" + } + }, + "addPool((address,uint8,bytes32,address,address,bool,bool,bool))": { + "details": "Before adding a meta pool, the user must first add the underlying base pool. Only Swap and MetaSwap contracts need to be added.", + "params": { + "inputData": "PoolInputData struct for the new pool" + } + }, + "approvePool(address)": { + "details": "since array entries are difficult to remove, we modify the entry to mark it as a Saddle owned pool.", + "params": { + "poolAddress": "address of the community pool" + } + }, + "batch(bytes[],bool)": { + "params": { + "calls": "An array of inputs for each call.", + "revertOnFail": "If True then reverts after a failed call and stops doing further calls." + } + }, + "constructor": { + "details": "caller of this function will be set as the owner on deployment", + "params": { + "admin": "address who should have the DEFAULT_ADMIN_ROLE" + } + }, + "getA(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getEligiblePools(address,address)": { + "params": { + "from": "address of the token to swap from", + "to": "address of the token to swap to" + }, + "returns": { + "eligiblePools": "array of pool addresses that can swap between from and to" + } + }, + "getPaused(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getPoolData(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getPoolDataAtIndex(uint256)": { + "params": { + "index": "index of the pool to read" + } + }, + "getPoolDataByName(bytes32)": { + "params": { + "poolName": "name of the pool to read" + } + }, + "getRoleAdmin(bytes32)": { + "details": "Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}." + }, + "getRoleMember(bytes32,uint256)": { + "details": "Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information." + }, + "getRoleMemberCount(bytes32)": { + "details": "Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role." + }, + "getSwapStorage(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getTokenBalances(address)": { + "params": { + "poolAddress": "address of the pool to look up the token balances for" + }, + "returns": { + "balances": "array of token balances" + } + }, + "getTokens(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getUnderlyingTokenBalances(address)": { + "params": { + "poolAddress": "address of the pool to look up the token balances for" + }, + "returns": { + "balances": "array of token balances" + } + }, + "getUnderlyingTokens(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "getVirtualPrice(address)": { + "params": { + "poolAddress": "address of the pool to read" + } + }, + "grantRole(bytes32,address)": { + "details": "Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role." + }, + "hasRole(bytes32,address)": { + "details": "Returns `true` if `account` has been granted `role`." + }, + "removePool(address)": { + "details": "Since arrays are not easily reducable, the entry will be marked as removed.", + "params": { + "poolAddress": "address of the pool to remove" + } + }, + "renounceRole(bytes32,address)": { + "details": "Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `account`." + }, + "revokeRole(bytes32,address)": { + "details": "Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role." + }, + "updatePool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "params": { + "poolData": "new PoolData struct to store" + } + } + }, + "stateVariables": { + "poolsIndexOfNamePlusOne": { + "params": { + "poolName": "pool name in bytes32 format to look for" + } + }, + "poolsIndexOfPlusOne": { + "params": { + "poolAddress": "address to look for" + } + } + }, + "title": "PoolRegistry", + "version": 1 + }, + "userdoc": { + "events": { + "AddCommunityPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "notice": "Add a new registry entry to the master list." + }, + "AddPool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "notice": "Add a new registry entry to the master list." + }, + "RemovePool(address,uint256)": { + "notice": "Add a new registry entry to the master list." + }, + "UpdatePool(address,uint256,(address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "notice": "Add a new registry entry to the master list." + } + }, + "kind": "user", + "methods": { + "COMMUNITY_MANAGER_ROLE()": { + "notice": "Role responsible for managing community pools" + }, + "SADDLE_APPROVED_POOL_OWNER_ROLE()": { + "notice": "Role that represents approved owners of pools. owner of each pool must have this role if the pool is to be approved." + }, + "SADDLE_MANAGER_ROLE()": { + "notice": "Role responsible for managing pools." + }, + "addCommunityPool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "notice": "Add a new pool to the registry" + }, + "addPool((address,uint8,bytes32,address,address,bool,bool,bool))": { + "notice": "Add a new pool to the registry" + }, + "approvePool(address)": { + "notice": "Approve community deployed pools to be upgraded as Saddle owned" + }, + "batch(bytes[],bool)": { + "notice": "Allows batched call to self (this contract)." + }, + "constructor": "Deploy this contract and set appropriate roles", + "getA(address)": { + "notice": "Returns A of the given pool address" + }, + "getEligiblePools(address,address)": { + "notice": "Returns an array of pool addresses that can swap between from and to" + }, + "getPaused(address)": { + "notice": "Returns the paused status of the given pool address" + }, + "getPoolData(address)": { + "notice": "Returns PoolData for given pool address" + }, + "getPoolDataAtIndex(uint256)": { + "notice": "Returns PoolData at given index" + }, + "getPoolDataByName(bytes32)": { + "notice": "Returns PoolData with given name" + }, + "getPoolsLength()": { + "notice": "Returns number of entries in the registry. Includes removed pools in the list as well." + }, + "getSwapStorage(address)": { + "notice": "Returns the SwapStorage struct of the given pool address" + }, + "getTokenBalances(address)": { + "notice": "Returns an array of balances of the tokens" + }, + "getTokens(address)": { + "notice": "Returns the tokens of the given pool address" + }, + "getUnderlyingTokenBalances(address)": { + "notice": "Returns an array of balances of the tokens" + }, + "getUnderlyingTokens(address)": { + "notice": "Returns the underlying tokens of the given pool address. Base pools will return an empty array." + }, + "getVirtualPrice(address)": { + "notice": "Returns virtual price of the given pool address" + }, + "poolsIndexOfNamePlusOne(bytes32)": { + "notice": "Returns the index + 1 of the pool name in the registry" + }, + "poolsIndexOfPlusOne(address)": { + "notice": "Returns the index + 1 of the pool address in the registry" + }, + "removePool(address)": { + "notice": "Remove pool from the registry" + }, + "updatePool((address,address,uint8,bytes32,address,address[],address[],address,address,bool,bool,bool))": { + "notice": "Overwrite existing entry with new PoolData" + } + }, + "notice": "This contract holds list of pools deployed.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1726, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "_roles", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)" + }, + { + "astId": 6134, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "_status", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 33760, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "poolsIndexOfPlusOne", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33766, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "poolsIndexOfNamePlusOne", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_bytes32,t_uint256)" + }, + { + "astId": 33769, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "pools", + "offset": 0, + "slot": "4", + "type": "t_array(t_struct(PoolData)24899_storage)dyn_storage" + }, + { + "astId": 33774, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "eligiblePairsMap", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_uint256,t_array(t_address)dyn_storage)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_bytes32)dyn_storage": { + "base": "t_bytes32", + "encoding": "dynamic_array", + "label": "bytes32[]", + "numberOfBytes": "32" + }, + "t_array(t_contract(IERC20)3311)dyn_storage": { + "base": "t_contract(IERC20)3311", + "encoding": "dynamic_array", + "label": "contract IERC20[]", + "numberOfBytes": "32" + }, + "t_array(t_struct(PoolData)24899_storage)dyn_storage": { + "base": "t_struct(PoolData)24899_storage", + "encoding": "dynamic_array", + "label": "struct IPoolRegistry.PoolData[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20)3311": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes32,t_struct(RoleData)1722_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct AccessControl.RoleData)", + "numberOfBytes": "32", + "value": "t_struct(RoleData)1722_storage" + }, + "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_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_struct(AddressSet)5815_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.AddressSet", + "members": [ + { + "astId": 5814, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "_inner", + "offset": 0, + "slot": "0", + "type": "t_struct(Set)5550_storage" + } + ], + "numberOfBytes": "64" + }, + "t_struct(PoolData)24899_storage": { + "encoding": "inplace", + "label": "struct IPoolRegistry.PoolData", + "members": [ + { + "astId": 24874, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "poolAddress", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 24876, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "lpToken", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 24878, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "typeOfAsset", + "offset": 20, + "slot": "1", + "type": "t_uint8" + }, + { + "astId": 24880, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "poolName", + "offset": 0, + "slot": "2", + "type": "t_bytes32" + }, + { + "astId": 24882, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "targetAddress", + "offset": 0, + "slot": "3", + "type": "t_address" + }, + { + "astId": 24885, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "tokens", + "offset": 0, + "slot": "4", + "type": "t_array(t_contract(IERC20)3311)dyn_storage" + }, + { + "astId": 24888, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "underlyingTokens", + "offset": 0, + "slot": "5", + "type": "t_array(t_contract(IERC20)3311)dyn_storage" + }, + { + "astId": 24890, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "basePoolAddress", + "offset": 0, + "slot": "6", + "type": "t_address" + }, + { + "astId": 24892, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "metaSwapDepositAddress", + "offset": 0, + "slot": "7", + "type": "t_address" + }, + { + "astId": 24894, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "isSaddleApproved", + "offset": 20, + "slot": "7", + "type": "t_bool" + }, + { + "astId": 24896, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "isRemoved", + "offset": 21, + "slot": "7", + "type": "t_bool" + }, + { + "astId": 24898, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "isGuarded", + "offset": 22, + "slot": "7", + "type": "t_bool" + } + ], + "numberOfBytes": "256" + }, + "t_struct(RoleData)1722_storage": { + "encoding": "inplace", + "label": "struct AccessControl.RoleData", + "members": [ + { + "astId": 1719, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "members", + "offset": 0, + "slot": "0", + "type": "t_struct(AddressSet)5815_storage" + }, + { + "astId": 1721, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "adminRole", + "offset": 0, + "slot": "2", + "type": "t_bytes32" + } + ], + "numberOfBytes": "96" + }, + "t_struct(Set)5550_storage": { + "encoding": "inplace", + "label": "struct EnumerableSet.Set", + "members": [ + { + "astId": 5545, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "_values", + "offset": 0, + "slot": "0", + "type": "t_array(t_bytes32)dyn_storage" + }, + { + "astId": 5549, + "contract": "contracts/registries/PoolRegistry.sol:PoolRegistry", + "label": "_indexes", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_bytes32,t_uint256)" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/SaddleDummyPool.json b/deployments/base_testnet/SaddleDummyPool.json new file mode 100644 index 00000000..e4c8569e --- /dev/null +++ b/deployments/base_testnet/SaddleDummyPool.json @@ -0,0 +1,1437 @@ +{ + "address": "0x47a303F4278AE7F970624C980A036868c5267AAa", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "AddLiquidity", + "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": "newAdminFee", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "NewSwapFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newWithdrawFee", + "type": "uint256" + } + ], + "name": "NewWithdrawFee", + "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": "uint256", + "name": "oldA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "initialTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "RampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidityImbalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "boughtId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + } + ], + "name": "RemoveLiquidityOne", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentA", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "StopRampA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "minToMint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "calculateRemoveLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + } + ], + "name": "calculateRemoveLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "availableTokenAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + } + ], + "name": "calculateSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "calculateTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getA", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAPrecise", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "getAdminBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "index", + "type": "uint8" + } + ], + "name": "getTokenBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + } + ], + "name": "getTokenIndex", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVirtualPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "_pooledTokens", + "type": "address[]" + }, + { + "internalType": "uint8[]", + "name": "decimals", + "type": "uint8[]" + }, + { + "internalType": "string", + "name": "lpTokenName", + "type": "string" + }, + { + "internalType": "string", + "name": "lpTokenSymbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "_a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "lpTokenTargetAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureTime", + "type": "uint256" + } + ], + "name": "rampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidity", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxBurnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityImbalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "tokenIndex", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "minAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "removeLiquidityOneToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "setAdminFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "setSwapFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "stopRampA", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "tokenIndexFrom", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "tokenIndexTo", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "dx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minDy", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "swapStorage", + "outputs": [ + { + "internalType": "uint256", + "name": "initialA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "futureATime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "contract LPTokenV2", + "name": "lpToken", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawAdminFees", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } + ], + "transactionHash": "0x984bd8596e1b45b2e0d36f46596bcd532ea287e94dd637beb786c7479818ce8f", + "receipt": { + "to": null, + "from": "0x5BDb37d0Ddea3A90F233c7B7F6b9394B6b2eef34", + "contractAddress": "0x47a303F4278AE7F970624C980A036868c5267AAa", + "transactionIndex": 1, + "gasUsed": "2686511", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x55291956683b0cbc6015028a846160f572c33a19d71fedee6309c6e66303147e", + "transactionHash": "0x984bd8596e1b45b2e0d36f46596bcd532ea287e94dd637beb786c7479818ce8f", + "logs": [], + "blockNumber": 2717508, + "cumulativeGasUsed": "2686511", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"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\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"NewSwapFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newWithdrawFee\",\"type\":\"uint256\"}],\"name\":\"NewWithdrawFee\",\"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\":\"uint256\",\"name\":\"oldA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"initialTime\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"RampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityImbalance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"boughtId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityOne\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"currentA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"}],\"name\":\"StopRampA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwap\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"minToMint\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"calculateRemoveLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"}],\"name\":\"calculateRemoveLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"availableTokenAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"}],\"name\":\"calculateSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"calculateTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getA\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAPrecise\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getAdminBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"index\",\"type\":\"uint8\"}],\"name\":\"getTokenBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"tokenAddress\",\"type\":\"address\"}],\"name\":\"getTokenIndex\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getVirtualPrice\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"_pooledTokens\",\"type\":\"address[]\"},{\"internalType\":\"uint8[]\",\"name\":\"decimals\",\"type\":\"uint8[]\"},{\"internalType\":\"string\",\"name\":\"lpTokenName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"lpTokenSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_adminFee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"lpTokenTargetAddress\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureTime\",\"type\":\"uint256\"}],\"name\":\"rampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"minAmounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"maxBurnAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityImbalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndex\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"minAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"removeLiquidityOneToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"setAdminFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"setSwapFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stopRampA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"tokenIndexFrom\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"tokenIndexTo\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"dx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDy\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapStorage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"initialA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initialATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"futureATime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adminFee\",\"type\":\"uint256\"},{\"internalType\":\"contract LPTokenV2\",\"name\":\"lpToken\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawAdminFees\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's deployment size.\",\"kind\":\"dev\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"deadline\":\"latest timestamp to accept this transaction\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation\"},\"returns\":{\"_0\":\"amount of LP token user minted and received\"}},\"calculateRemoveLiquidity(uint256)\":{\"params\":{\"amount\":\"the amount of LP tokens that would be burned on withdrawal\"},\"returns\":{\"_0\":\"array of token balances that the user will receive\"}},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"params\":{\"tokenAmount\":\"the amount of LP token to burn\",\"tokenIndex\":\"index of which token will be withdrawn\"},\"returns\":{\"availableTokenAmount\":\"calculated amount of underlying token available to withdraw\"}},\"calculateSwap(uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of tokens the user will receive\"}},\"calculateTokenAmount(uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\"},\"returns\":{\"_0\":\"token amount the user will receive\"}},\"getA()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter\"}},\"getAPrecise()\":{\"details\":\"See the StableSwap paper for details\",\"returns\":{\"_0\":\"A parameter in its raw precision form\"}},\"getAdminBalance(uint256)\":{\"params\":{\"index\":\"Index of the pooled token\"},\"returns\":{\"_0\":\"admin's token balance in the token's precision\"}},\"getToken(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"address of the token at given index\"}},\"getTokenBalance(uint8)\":{\"params\":{\"index\":\"the index of the token\"},\"returns\":{\"_0\":\"current balance of the pooled token at given index with token's native precision\"}},\"getTokenIndex(address)\":{\"params\":{\"tokenAddress\":\"address of the token\"},\"returns\":{\"_0\":\"the index of the given token address\"}},\"getVirtualPrice()\":{\"returns\":{\"_0\":\"the virtual price, scaled to the POOL_PRECISION_DECIMALS\"}},\"initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)\":{\"params\":{\"_a\":\"the amplification coefficient * n * (n - 1). See the StableSwap paper for details\",\"_adminFee\":\"default adminFee to be initialized with\",\"_fee\":\"default swap fee to be initialized with\",\"_pooledTokens\":\"an array of ERC20s this pool will accept\",\"decimals\":\"the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\",\"lpTokenName\":\"the long-form name of the token to be deployed\",\"lpTokenSymbol\":\"the short symbol for the token to be deployed\",\"lpTokenTargetAddress\":\"the address of an existing LPToken contract to use as a target\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"rampA(uint256,uint256)\":{\"params\":{\"futureA\":\"the new A to ramp towards\",\"futureTime\":\"timestamp when the new A should be reached\"}},\"removeLiquidity(uint256,uint256[],uint256)\":{\"details\":\"Liquidity can always be removed, even when the pool is paused.\",\"params\":{\"amount\":\"the amount of LP tokens to burn\",\"deadline\":\"latest timestamp to accept this transaction\",\"minAmounts\":\"the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation\"},\"returns\":{\"_0\":\"amounts of tokens user received\"}},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"deadline\":\"latest timestamp to accept this transaction\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\"},\"returns\":{\"_0\":\"amount of LP tokens burned\"}},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"tokenAmount\":\"the amount of the token you want to receive\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount of chosen token user received\"}},\"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.\"},\"setAdminFee(uint256)\":{\"params\":{\"newAdminFee\":\"new admin fee to be applied on future transactions\"}},\"setSwapFee(uint256)\":{\"params\":{\"newSwapFee\":\"new swap fee to be applied on future transactions\"}},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"params\":{\"deadline\":\"latest timestamp to accept this transaction\",\"dx\":\"the amount of tokens the user wants to swap from\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"tokenIndexFrom\":\"the token the user wants to swap from\",\"tokenIndexTo\":\"the token the user wants to swap to\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Swap - A StableSwap implementation in solidity.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(uint256[],uint256,uint256)\":{\"notice\":\"Add liquidity to the pool with the given amounts of tokens\"},\"calculateRemoveLiquidity(uint256)\":{\"notice\":\"A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens\"},\"calculateRemoveLiquidityOneToken(uint256,uint8)\":{\"notice\":\"Calculate the amount of underlying token available to withdraw when withdrawing via only single token\"},\"calculateSwap(uint8,uint8,uint256)\":{\"notice\":\"Calculate amount of tokens you receive on swap\"},\"calculateTokenAmount(uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running\"},\"getA()\":{\"notice\":\"Return A, the amplification coefficient * n * (n - 1)\"},\"getAPrecise()\":{\"notice\":\"Return A in its raw precision form\"},\"getAdminBalance(uint256)\":{\"notice\":\"This function reads the accumulated amount of admin fees of the token with given index\"},\"getToken(uint8)\":{\"notice\":\"Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\"},\"getTokenBalance(uint8)\":{\"notice\":\"Return current balance of the pooled token at given index\"},\"getTokenIndex(address)\":{\"notice\":\"Return the index of the given token address. Reverts if no matching token is found.\"},\"getVirtualPrice()\":{\"notice\":\"Get the virtual price, to help calculate profit\"},\"initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)\":{\"notice\":\"Initializes this Swap contract with the given parameters. This will also clone a LPToken contract that represents users' LP positions. The owner of LPToken will be this contract - which means only this contract is allowed to mint/burn tokens.\"},\"pause()\":{\"notice\":\"Pause the contract. Revert if already paused.\"},\"rampA(uint256,uint256)\":{\"notice\":\"Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range.\"},\"removeLiquidity(uint256,uint256[],uint256)\":{\"notice\":\"Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityImbalance(uint256[],uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"removeLiquidityOneToken(uint256,uint8,uint256,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply.\"},\"setAdminFee(uint256)\":{\"notice\":\"Update the admin fee. Admin fee takes portion of the swap fee.\"},\"setSwapFee(uint256)\":{\"notice\":\"Update the swap fee to be applied on swaps\"},\"stopRampA()\":{\"notice\":\"Stop ramping A immediately. Reverts if ramp A is already stopped.\"},\"swap(uint8,uint8,uint256,uint256,uint256)\":{\"notice\":\"Swap two tokens using this pool\"},\"unpause()\":{\"notice\":\"Unpause the contract. Revert if already unpaused.\"},\"withdrawAdminFees()\":{\"notice\":\"Withdraw all admin fees to the contract owner\"}},\"notice\":\"This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/SwapV2.sol\":\"SwapV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/proxy/Clones.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\\n * deploying minimal proxy contracts, also known as \\\"clones\\\".\\n *\\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\\n *\\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\\n * deterministic method.\\n *\\n * _Available since v3.4._\\n */\\nlibrary Clones {\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\\n *\\n * This function uses the create opcode, which should never revert.\\n */\\n function clone(address implementation) internal returns (address instance) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create(0, ptr, 0x37)\\n }\\n require(instance != address(0), \\\"ERC1167: create failed\\\");\\n }\\n\\n /**\\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\\n *\\n * This function uses the create2 opcode and a `salt` to deterministically deploy\\n * the clone. Using the same `implementation` and `salt` multiple time will revert, since\\n * the clones cannot be deployed twice at the same address.\\n */\\n function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\\n instance := create2(0, ptr, 0x37, salt)\\n }\\n require(instance != address(0), \\\"ERC1167: create2 failed\\\");\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(\\n address implementation,\\n bytes32 salt,\\n address deployer\\n ) internal pure returns (address predicted) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\\n mstore(add(ptr, 0x14), shl(0x60, implementation))\\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\\n mstore(add(ptr, 0x38), shl(0x60, deployer))\\n mstore(add(ptr, 0x4c), salt)\\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\\n predicted := keccak256(add(ptr, 0x37), 0x55)\\n }\\n }\\n\\n /**\\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\\n */\\n function predictDeterministicAddress(address implementation, bytes32 salt)\\n internal\\n view\\n returns (address predicted)\\n {\\n return predictDeterministicAddress(implementation, salt, address(this));\\n }\\n}\\n\",\"keccak256\":\"0xae614c6b103b743c62e9544632f7ef4fc8950de4e9c783d2e765a3b86701dda3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/security/ReentrancyGuardUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuardUpgradeable is Initializable {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n function __ReentrancyGuard_init() internal onlyInitializing {\\n __ReentrancyGuard_init_unchained();\\n }\\n\\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\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\":\"0x8cc03c5ac17e8a7396e487cda41fc1f1dfdb91db7d528e6da84bee3b6dd7e167\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/AmplificationUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./SwapUtilsV2.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtilsV2 {\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return (_getAPrecise(self) / A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtilsV2.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return a0 + (((a1 - a0) * (block.timestamp - t0)) / (t1 - t0));\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return a0 - (((a0 - a1) * (block.timestamp - t0)) / (t1 - t0));\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtilsV2.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= (self.initialATime + (1 days)),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= (block.timestamp + MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_ * A_PRECISION;\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n (futureAPrecise * MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= (initialAPrecise * MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtilsV2.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0xb52146d1964ede58f1cb59bff4fa507d30eeae9b11c213941bcbda047fe9e4fb\",\"license\":\"MIT\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/MathUtilsV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtilsV1 {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x39534ffe365ac4796eebdd5d505ed58c425bc65861ccf118eb0f6cd26c654f0b\",\"license\":\"MIT\"},\"contracts/OwnerPausableUpgradeableV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/security/PausableUpgradeable.sol\\\";\\n\\n/**\\n * @title OwnerPausable\\n * @notice An ownable contract allows the owner to pause and unpause the\\n * contract without a delay.\\n * @dev Only methods using the provided modifiers will be paused.\\n */\\nabstract contract OwnerPausableUpgradeableV1 is\\n OwnableUpgradeable,\\n PausableUpgradeable\\n{\\n function __OwnerPausable_init() internal onlyInitializing {\\n __Context_init_unchained();\\n __Ownable_init_unchained();\\n __Pausable_init_unchained();\\n }\\n\\n /**\\n * @notice Pause the contract. Revert if already paused.\\n */\\n function pause() external onlyOwner {\\n PausableUpgradeable._pause();\\n }\\n\\n /**\\n * @notice Unpause the contract. Revert if already unpaused.\\n */\\n function unpause() external onlyOwner {\\n PausableUpgradeable._unpause();\\n }\\n}\\n\",\"keccak256\":\"0x977a49e6e11fb7972a29df83b5377f85fe76a1dfa1ba8f5ae708a76243b0d1bc\",\"license\":\"MIT\"},\"contracts/SwapUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtilsV2.sol\\\";\\nimport \\\"./LPTokenV2.sol\\\";\\nimport \\\"./MathUtilsV1.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtilsV2 {\\n using SafeERC20 for IERC20;\\n using MathUtilsV1 for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPTokenV2 lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPTokenV2 lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount * (fee) / (FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtilsV2._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = ((currentY - newY) /\\n self.tokenPrecisionMultipliers[tokenIndex]) - dy;\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] =\\n xpi -\\n (((\\n (i == tokenIndex)\\n ? ((xpi * v.d1) / v.d0) - v.newY\\n : xpi - ((xpi * v.d1) / v.d0)\\n ) * v.feePerToken) / FEE_DENOMINATOR);\\n }\\n\\n uint256 dy = xpReduced[tokenIndex] -\\n (getYD(v.preciseA, tokenIndex, xpReduced, v.d1));\\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a * (numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s + xp[i];\\n c = (c * d) / (xp[i] * (numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = ((y * y) + c) / ((y * 2) + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s + xp[i];\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a * numTokens;\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = (dP * d) / (xp[j] * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d =\\n ((((nA * s) / AmplificationUtilsV2.A_PRECISION) +\\n (dP * numTokens)) * d) /\\n ((((nA - AmplificationUtilsV2.A_PRECISION) * d) /\\n AmplificationUtilsV2.A_PRECISION) + ((numTokens + 1) * dP));\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i] * precisionMultipliers[i];\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPTokenV2 lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return (d * (10**uint256(POOL_PRECISION_DECIMALS))) / supply;\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens * preciseA;\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s + _x;\\n c = (c * d) / (_x * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = (y * y + c) / (y * 2 + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx * multipliers[tokenIndexFrom] + xp[tokenIndexFrom];\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo] - y - 1;\\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\\n dy = (dy - dyFee) / multipliers[tokenIndexTo];\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = (balances[i] * amount) / totalSupply;\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i] + amounts[i];\\n } else {\\n if (amounts[i] > balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances[i] = balances[i] - amounts[i];\\n }\\n }\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return (((d1 - d0) * totalSupply) / d0);\\n } else {\\n return (((d0 - d1) * totalSupply) / d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)) -\\n self.balances[index];\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return ((swapFee * numTokens) / ((numTokens - 1) * 4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)) - beforeBalance;\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = (((dyFee * self.adminFee) / FEE_DENOMINATOR) /\\n self.tokenPrecisionMultipliers[tokenIndexTo]);\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom] + dx;\\n self.balances[tokenIndexTo] = balances[tokenIndexTo] - dy - dyAdminFee;\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] =\\n pooledTokens[i].balanceOf(address(this)) -\\n beforeBalance;\\n }\\n\\n newBalances[i] = v.balances[i] + amounts[i];\\n }\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n fees[i] =\\n (feePerToken * idealBalance.difference(newBalances[i])) /\\n FEE_DENOMINATOR;\\n self.balances[i] =\\n newBalances[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n newBalances[i] = newBalances[i] - fees[i];\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply + toMint\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i] - amounts[i];\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply - amount);\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] =\\n self.balances[tokenIndex] -\\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n if (amounts[i] > v.balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = v.balances[i] - amounts[i];\\n }\\n }\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\\n self.balances[i] =\\n balances1[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n balances1[i] = balances1[i] - fees[i];\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount + 1;\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply - tokenAmount\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)) - self.balances[i];\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0xb8d3f47b58b85bddeeb59cc13049f3f7fee2b29ee373fe5427d1f7c8814a1b8b\",\"license\":\"MIT\"},\"contracts/SwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts-4.7.3/proxy/Clones.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/security/ReentrancyGuardUpgradeable.sol\\\";\\nimport \\\"./OwnerPausableUpgradeableV1.sol\\\";\\nimport \\\"./SwapUtilsV2.sol\\\";\\nimport \\\"./AmplificationUtilsV2.sol\\\";\\n\\n/**\\n * @title Swap - A StableSwap implementation in solidity.\\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\\n * Users can burn pool tokens and withdraw their share of token(s).\\n *\\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\\n * distributed to the LPs.\\n *\\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\\n * stops the ratio of the tokens in the pool from changing.\\n * Users can always withdraw their tokens via multi-asset withdraws.\\n *\\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\\n * deployment size.\\n */\\ncontract SwapV2 is OwnerPausableUpgradeableV1, ReentrancyGuardUpgradeable {\\n using SafeERC20 for IERC20;\\n using SwapUtilsV2 for SwapUtilsV2.Swap;\\n using AmplificationUtilsV2 for SwapUtilsV2.Swap;\\n\\n // Struct storing data responsible for automatic market maker functionalities. In order to\\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtils.sol\\n SwapUtilsV2.Swap public swapStorage;\\n\\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\\n // getTokenIndex function also relies on this mapping to retrieve token index.\\n mapping(address => uint8) private tokenIndexes;\\n\\n /*** EVENTS ***/\\n\\n // events replicated from SwapUtils to make the ABI easier for dumb\\n // clients\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n event NewWithdrawFee(uint256 newWithdrawFee);\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n /**\\n * @notice Initializes this Swap contract with the given parameters.\\n * This will also clone a LPToken contract that represents users'\\n * LP positions. The owner of LPToken will be this contract - which means\\n * only this contract is allowed to mint/burn tokens.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\\n */\\n function initialize(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) public payable virtual initializer {\\n __SwapV2_init(\\n _pooledTokens,\\n decimals,\\n lpTokenName,\\n lpTokenSymbol,\\n _a,\\n _fee,\\n _adminFee,\\n lpTokenTargetAddress\\n );\\n }\\n\\n /**\\n * @notice Initializes this Swap contract with the given parameters.\\n * This will also clone a LPToken contract that represents users'\\n * LP positions. The owner of LPToken will be this contract - which means\\n * only this contract is allowed to mint/burn tokens.\\n *\\n * @param _pooledTokens an array of ERC20s this pool will accept\\n * @param decimals the decimals to use for each pooled token,\\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\\n * @param lpTokenName the long-form name of the token to be deployed\\n * @param lpTokenSymbol the short symbol for the token to be deployed\\n * @param _a the amplification coefficient * n * (n - 1). See the\\n * StableSwap paper for details\\n * @param _fee default swap fee to be initialized with\\n * @param _adminFee default adminFee to be initialized with\\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\\n */\\n function __SwapV2_init(\\n IERC20[] memory _pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 _a,\\n uint256 _fee,\\n uint256 _adminFee,\\n address lpTokenTargetAddress\\n ) internal virtual onlyInitializing {\\n __OwnerPausable_init();\\n __ReentrancyGuard_init();\\n // Check _pooledTokens and precisions parameter\\n require(_pooledTokens.length > 1, \\\"_pooledTokens.length <= 1\\\");\\n require(_pooledTokens.length <= 32, \\\"_pooledTokens.length > 32\\\");\\n require(\\n _pooledTokens.length == decimals.length,\\n \\\"_pooledTokens decimals mismatch\\\"\\n );\\n\\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\\n\\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\\n if (i > 0) {\\n // Check if index is already used. Check if 0th element is a duplicate.\\n require(\\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\\n _pooledTokens[0] != _pooledTokens[i],\\n \\\"Duplicate tokens\\\"\\n );\\n }\\n require(\\n address(_pooledTokens[i]) != address(0),\\n \\\"The 0 address isn't an ERC-20\\\"\\n );\\n require(\\n decimals[i] <= SwapUtilsV2.POOL_PRECISION_DECIMALS,\\n \\\"Token decimals exceeds max\\\"\\n );\\n precisionMultipliers[i] =\\n 10 **\\n (uint256(SwapUtilsV2.POOL_PRECISION_DECIMALS) -\\n uint256(decimals[i]));\\n tokenIndexes[address(_pooledTokens[i])] = i;\\n }\\n\\n // Check _a, _fee, _adminFee, _withdrawFee parameters\\n require(_a < AmplificationUtilsV2.MAX_A, \\\"_a exceeds maximum\\\");\\n require(_fee < SwapUtilsV2.MAX_SWAP_FEE, \\\"_fee exceeds maximum\\\");\\n require(\\n _adminFee < SwapUtilsV2.MAX_ADMIN_FEE,\\n \\\"_adminFee exceeds maximum\\\"\\n );\\n\\n // Clone and initialize a LPToken contract\\n LPTokenV2 lpToken = LPTokenV2(Clones.clone(lpTokenTargetAddress));\\n require(\\n lpToken.initialize(lpTokenName, lpTokenSymbol),\\n \\\"could not init lpToken clone\\\"\\n );\\n\\n // Initialize swapStorage struct\\n swapStorage.lpToken = lpToken;\\n swapStorage.pooledTokens = _pooledTokens;\\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\\n swapStorage.balances = new uint256[](_pooledTokens.length);\\n swapStorage.initialA = _a * AmplificationUtilsV2.A_PRECISION;\\n swapStorage.futureA = _a * AmplificationUtilsV2.A_PRECISION;\\n // swapStorage.initialATime = 0;\\n // swapStorage.futureATime = 0;\\n swapStorage.swapFee = _fee;\\n swapStorage.adminFee = _adminFee;\\n }\\n\\n /*** MODIFIERS ***/\\n\\n /**\\n * @notice Modifier to check deadline against current timestamp\\n * @param deadline latest timestamp to accept this transaction\\n */\\n modifier deadlineCheck(uint256 deadline) {\\n require(block.timestamp <= deadline, \\\"Deadline not met\\\");\\n _;\\n }\\n\\n /*** VIEW FUNCTIONS ***/\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @return A parameter\\n */\\n function getA() external view virtual returns (uint256) {\\n return swapStorage.getA();\\n }\\n\\n /**\\n * @notice Return A in its raw precision form\\n * @dev See the StableSwap paper for details\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise() external view virtual returns (uint256) {\\n return swapStorage.getAPrecise();\\n }\\n\\n /**\\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\\n * @param index the index of the token\\n * @return address of the token at given index\\n */\\n function getToken(uint8 index) public view virtual returns (IERC20) {\\n require(index < swapStorage.pooledTokens.length, \\\"Out of range\\\");\\n return swapStorage.pooledTokens[index];\\n }\\n\\n /**\\n * @notice Return the index of the given token address. Reverts if no matching\\n * token is found.\\n * @param tokenAddress address of the token\\n * @return the index of the given token address\\n */\\n function getTokenIndex(address tokenAddress)\\n public\\n view\\n virtual\\n returns (uint8)\\n {\\n uint8 index = tokenIndexes[tokenAddress];\\n require(\\n address(getToken(index)) == tokenAddress,\\n \\\"Token does not exist\\\"\\n );\\n return index;\\n }\\n\\n /**\\n * @notice Return current balance of the pooled token at given index\\n * @param index the index of the token\\n * @return current balance of the pooled token at given index with token's native precision\\n */\\n function getTokenBalance(uint8 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n require(index < swapStorage.pooledTokens.length, \\\"Index out of range\\\");\\n return swapStorage.balances[index];\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice() external view virtual returns (uint256) {\\n return swapStorage.getVirtualPrice();\\n }\\n\\n /**\\n * @notice Calculate amount of tokens you receive on swap\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell. If the token charges\\n * a fee on transfers, use the amount that gets transferred after the fee.\\n * @return amount of tokens the user will receive\\n */\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view virtual returns (uint256) {\\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return token amount the user will receive\\n */\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.calculateTokenAmount(amounts, deposit);\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of LP tokens\\n * @param amount the amount of LP tokens that would be burned on withdrawal\\n * @return array of token balances that the user will receive\\n */\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n virtual\\n returns (uint256[] memory)\\n {\\n return swapStorage.calculateRemoveLiquidity(amount);\\n }\\n\\n /**\\n * @notice Calculate the amount of underlying token available to withdraw\\n * when withdrawing via only single token\\n * @param tokenAmount the amount of LP token to burn\\n * @param tokenIndex index of which token will be withdrawn\\n * @return availableTokenAmount calculated amount of underlying token\\n * available to withdraw\\n */\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view virtual returns (uint256 availableTokenAmount) {\\n return swapStorage.calculateWithdrawOneToken(tokenAmount, tokenIndex);\\n }\\n\\n /**\\n * @notice This function reads the accumulated amount of admin fees of the token with given index\\n * @param index Index of the pooled token\\n * @return admin's token balance in the token's precision\\n */\\n function getAdminBalance(uint256 index)\\n external\\n view\\n virtual\\n returns (uint256)\\n {\\n return swapStorage.getAdminBalance(index);\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice Swap two tokens using this pool\\n * @param tokenIndexFrom the token the user wants to swap from\\n * @param tokenIndexTo the token the user wants to swap to\\n * @param dx the amount of tokens the user wants to swap from\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @param deadline latest timestamp to accept this transaction\\n */\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\\n }\\n\\n /**\\n * @notice Add liquidity to the pool with the given amounts of tokens\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP token user minted and received\\n */\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.addLiquidity(amounts, minToMint);\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @param deadline latest timestamp to accept this transaction\\n * @return amounts of tokens user received\\n */\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n deadlineCheck(deadline)\\n returns (uint256[] memory)\\n {\\n return swapStorage.removeLiquidity(amount, minAmounts);\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param tokenAmount the amount of the token you want to receive\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of chosen token user received\\n */\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return\\n swapStorage.removeLiquidityOneToken(\\n tokenAmount,\\n tokenIndex,\\n minAmount\\n );\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances. Withdraw fee that decays linearly\\n * over period of 4 weeks since last deposit will apply.\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @param deadline latest timestamp to accept this transaction\\n * @return amount of LP tokens burned\\n */\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n )\\n external\\n payable\\n virtual\\n nonReentrant\\n whenNotPaused\\n deadlineCheck(deadline)\\n returns (uint256)\\n {\\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\\n }\\n\\n /*** ADMIN FUNCTIONS ***/\\n\\n /**\\n * @notice Withdraw all admin fees to the contract owner\\n */\\n function withdrawAdminFees() external payable virtual onlyOwner {\\n swapStorage.withdrawAdminFees(owner());\\n }\\n\\n /**\\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(uint256 newAdminFee) external payable onlyOwner {\\n swapStorage.setAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice Update the swap fee to be applied on swaps\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(uint256 newSwapFee) external payable onlyOwner {\\n swapStorage.setSwapFee(newSwapFee);\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param futureA the new A to ramp towards\\n * @param futureTime timestamp when the new A should be reached\\n */\\n function rampA(uint256 futureA, uint256 futureTime)\\n external\\n payable\\n onlyOwner\\n {\\n swapStorage.rampA(futureA, futureTime);\\n }\\n\\n /**\\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\\n */\\n function stopRampA() external payable onlyOwner {\\n swapStorage.stopRampA();\\n }\\n}\\n\",\"keccak256\":\"0x892f2f7fde92c0e8b66fee8e2a90d9ff01485a2dd6ef082d6ea7a787b5cb91ba\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50612fde806100206000396000f3fe6080604052600436106101c25760003560e01c80638456cb59116100f7578063b28cb6dc11610095578063e6ab280611610064578063e6ab2806146104d7578063ef0a712f146104f7578063f2fad2b614610517578063f2fde38b1461053757600080fd5b8063b28cb6dc14610492578063c4db7fa0146104a5578063d46300fd146104ad578063e25aa5fa146104c257600080fd5b80638da5cb5b116100d15780638da5cb5b14610414578063916955861461043f57806391ceb3eb14610452578063a95b089f1461047257600080fd5b80638456cb59146103d957806384cdd9bc146103ee5780638beb60b61461040157600080fd5b80634d49e87d116101645780635fd65f0f1161013e5780635fd65f0f146102bd57806366c0bd241461034d578063715018a61461037f57806382b866001461039457600080fd5b80634d49e87d14610274578063593d132c146102875780635c975abb1461029a57600080fd5b8063342a87a1116101a0578063342a87a11461021957806334e19907146102395780633e3a15601461024c5780633f4ba83a1461025f57600080fd5b80630419b45a146101c75780630ba81959146101d157806331cd52b0146101f9575b600080fd5b6101cf610557565b005b3480156101dd57600080fd5b506101e661061f565b6040519081526020015b60405180910390f35b61020c6102073660046125d9565b6106b5565b6040516101f0919061262c565b34801561022557600080fd5b506101e6610234366004612681565b61082d565b6101cf6102473660046126ad565b6108d6565b6101e661025a3660046126c6565b610965565b34801561026b57600080fd5b506101cf610abc565b6101e6610282366004612701565b610ace565b6101cf610295366004612752565b610bd7565b3480156102a657600080fd5b5060655460ff1660405190151581526020016101f0565b3480156102c957600080fd5b5060c95460ca5460cb5460cc5460cd5460ce5460cf546103029695949392919073ffffffffffffffffffffffffffffffffffffffff1687565b604080519788526020880196909652948601939093526060850191909152608084015260a083015273ffffffffffffffffffffffffffffffffffffffff1660c082015260e0016101f0565b34801561035957600080fd5b5061036d6103683660046127a1565b610c6d565b60405160ff90911681526020016101f0565b34801561038b57600080fd5b506101cf610d07565b3480156103a057600080fd5b506103b46103af3660046127c5565b610d19565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101f0565b3480156103e557600080fd5b506101cf610daf565b6101e66103fc366004612701565b610dbf565b6101cf61040f3660046126ad565b610ec8565b34801561042057600080fd5b5060335473ffffffffffffffffffffffffffffffffffffffff166103b4565b6101e661044d3660046127e0565b610f28565b34801561045e57600080fd5b506101e661046d3660046127c5565b611096565b34801561047e57600080fd5b506101e661048d36600461282d565b611116565b6101cf6104a0366004612a6f565b6111c7565b6101cf61134f565b3480156104b957600080fd5b506101e66113a8565b3480156104ce57600080fd5b506101e66113fc565b3480156104e357600080fd5b506101e66104f2366004612b58565b611450565b34801561050357600080fd5b506101e66105123660046126ad565b6114aa565b34801561052357600080fd5b5061020c6105323660046126ad565b611541565b34801561054357600080fd5b506101cf6105523660046127a1565b6115fa565b61055f611697565b734a5208f83a17e030a18830521e4064e80728c4fc63fe7cb1c060c961059a60335473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925273ffffffffffffffffffffffffffffffffffffffff1660248201526044015b60006040518083038186803b15801561060557600080fd5b505af4158015610619573d6000803e3d6000fd5b50505050565b6040517fc4a241f700000000000000000000000000000000000000000000000000000000815260c9600482015260009073FdA5D2ad8b6d3884AbB799DA66f57175E87069419063c4a241f7906024015b602060405180830381865af415801561068c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b09190612baf565b905090565b606060026097540361070e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260975581428110156107645760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517ffa76ee2a000000000000000000000000000000000000000000000000000000008152734a5208f83a17e030a18830521e4064e80728c4fc9063fa76ee2a906107bb9060c9908a908a908a90600401612c13565b600060405180830381865af41580156107d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261081e9190810190612c3d565b60016097559695505050505050565b6040517f1a535da500000000000000000000000000000000000000000000000000000000815260c960048201526024810183905260ff82166044820152600090734a5208f83a17e030a18830521e4064e80728c4fc90631a535da590606401602060405180830381865af41580156108a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108cd9190612baf565b90505b92915050565b6108de611697565b6040517f05f7ec2100000000000000000000000000000000000000000000000000000000815260c9600482015260248101829052734a5208f83a17e030a18830521e4064e80728c4fc906305f7ec21906044015b60006040518083038186803b15801561094a57600080fd5b505af415801561095e573d6000803e3d6000fd5b5050505050565b60006002609754036109b95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b60026097556109c66116fe565b8180421115610a175760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f711cd33000000000000000000000000000000000000000000000000000000000815260c960048201526024810187905260ff8616604482015260648101859052734a5208f83a17e030a18830521e4064e80728c4fc9063711cd330906084015b602060405180830381865af4158015610a98573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e9190612baf565b610ac4611697565b610acc611751565b565b6000600260975403610b225760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610b2f6116fe565b8180421115610b805760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f041894b0000000000000000000000000000000000000000000000000000000008152734a5208f83a17e030a18830521e4064e80728c4fc9063041894b090610a7b9060c9908a908a908a90600401612cce565b610bdf611697565b6040517f858490d300000000000000000000000000000000000000000000000000000000815260c96004820152602481018390526044810182905273FdA5D2ad8b6d3884AbB799DA66f57175E87069419063858490d39060640160006040518083038186803b158015610c5157600080fd5b505af4158015610c65573d6000803e3d6000fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260d36020526040812054909160ff90911690610ca482610d19565b73ffffffffffffffffffffffffffffffffffffffff16146108d05760405162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f742065786973740000000000000000000000006044820152606401610705565b610d0f611697565b610acc60006117ce565b60d05460009060ff831610610d705760405162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e676500000000000000000000000000000000000000006044820152606401610705565b60d0805460ff8416908110610d8757610d87612cf9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1692915050565b610db7611697565b610acc611845565b6000600260975403610e135760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610e206116fe565b8180421115610e715760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f4540fb7f000000000000000000000000000000000000000000000000000000008152734a5208f83a17e030a18830521e4064e80728c4fc90634540fb7f90610a7b9060c9908a908a908a90600401612cce565b610ed0611697565b6040517fa125d92400000000000000000000000000000000000000000000000000000000815260c9600482015260248101829052734a5208f83a17e030a18830521e4064e80728c4fc9063a125d92490604401610932565b6000600260975403610f7c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610f896116fe565b8180421115610fda5760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517facf9147800000000000000000000000000000000000000000000000000000000815260c9600482015260ff8089166024830152871660448201526064810186905260848101859052734a5208f83a17e030a18830521e4064e80728c4fc9063acf914789060a401602060405180830381865af4158015611062573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110869190612baf565b6001609755979650505050505050565b60d05460009060ff8316106110ed5760405162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e676500000000000000000000000000006044820152606401610705565b60d2805460ff841690811061110457611104612cf9565b90600052602060002001549050919050565b6040517f39e43af200000000000000000000000000000000000000000000000000000000815260c9600482015260ff80851660248301528316604482015260648101829052600090734a5208f83a17e030a18830521e4064e80728c4fc906339e43af2906084015b602060405180830381865af415801561119b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bf9190612baf565b949350505050565b600054610100900460ff16158080156111e75750600054600160ff909116105b806112015750303b158015611201575060005460ff166001145b6112735760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610705565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156112d157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6112e189898989898989896118a0565b801561134457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b611357611697565b6040517fd3a605a500000000000000000000000000000000000000000000000000000000815260c9600482015273FdA5D2ad8b6d3884AbB799DA66f57175E87069419063d3a605a5906024016105ed565b6040517f1c103df000000000000000000000000000000000000000000000000000000000815260c9600482015260009073FdA5D2ad8b6d3884AbB799DA66f57175E870694190631c103df09060240161066f565b6040517f98a20a3e00000000000000000000000000000000000000000000000000000000815260c96004820152600090734a5208f83a17e030a18830521e4064e80728c4fc906398a20a3e9060240161066f565b6040517f6972fae8000000000000000000000000000000000000000000000000000000008152600090734a5208f83a17e030a18830521e4064e80728c4fc90636972fae89061117e9060c990889088908890600401612d28565b6040517fcbc7f8dd00000000000000000000000000000000000000000000000000000000815260c9600482015260248101829052600090734a5208f83a17e030a18830521e4064e80728c4fc9063cbc7f8dd90604401602060405180830381865af415801561151d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d09190612baf565b6040517f8424905f00000000000000000000000000000000000000000000000000000000815260c9600482015260248101829052606090734a5208f83a17e030a18830521e4064e80728c4fc90638424905f90604401600060405180830381865af41580156115b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526108d09190810190612c3d565b611602611697565b73ffffffffffffffffffffffffffffffffffffffff811661168b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610705565b611694816117ce565b50565b60335473ffffffffffffffffffffffffffffffffffffffff163314610acc5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610705565b60655460ff1615610acc5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610705565b611759612051565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61184d6116fe565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117a43390565b600054610100900460ff1661191d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b6119256120a3565b61192d612138565b600188511161197e5760405162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d2031000000000000006044820152606401610705565b6020885111156119d05760405162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e203332000000000000006044820152606401610705565b8651885114611a215760405162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d61746368006044820152606401610705565b6000875167ffffffffffffffff811115611a3d57611a3d612869565b604051908082528060200260200182016040528015611a66578160200160208202803683370190505b50905060005b89518160ff161015611d765760ff811615611b895760d360008b8360ff1681518110611a9a57611a9a612cf9565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff1682528101919091526040016000205460ff16158015611b3d5750898160ff1681518110611aeb57611aeb612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168a600081518110611b1c57611b1c612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614155b611b895760405162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e73000000000000000000000000000000006044820152606401610705565b600073ffffffffffffffffffffffffffffffffffffffff168a8260ff1681518110611bb657611bb6612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1603611c215760405162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d32300000006044820152606401610705565b601260ff16898260ff1681518110611c3b57611c3b612cf9565b602002602001015160ff161115611c945760405162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d61780000000000006044820152606401610705565b888160ff1681518110611ca957611ca9612cf9565b602002602001015160ff16601260ff16611cc39190612d84565b611cce90600a612eb7565b828260ff1681518110611ce357611ce3612cf9565b6020026020010181815250508060d360008c8460ff1681518110611d0957611d09612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508080611d6e90612ec3565b915050611a6c565b50620f42408510611dc95760405162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d00000000000000000000000000006044820152606401610705565b6305f5e1008410611e1c5760405162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d0000000000000000000000006044820152606401610705565b6402540be4008310611e705760405162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d000000000000006044820152606401610705565b6000611e7b836121bd565b6040517f4cd88b7600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff821690634cd88b7690611ed2908b908b90600401612f46565b6020604051808303816000875af1158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f159190612f74565b611f615760405162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e65000000006044820152606401610705565b60cf80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790558951611fb49060d09060208d01906124b3565b508151611fc89060d190602085019061253d565b50895167ffffffffffffffff811115611fe357611fe3612869565b60405190808252806020026020018201604052801561200c578160200160208202803683370190505b5080516120219160d29160209091019061253d565b5061202d606487612f91565b60c95561203b606487612f91565b60ca5550505060cd9190915560ce555050505050565b60655460ff16610acc5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610705565b600054610100900460ff166121205760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b612128612285565b612130612302565b610acc612388565b600054610100900460ff166121b55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b610acc61242f565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f091505073ffffffffffffffffffffffffffffffffffffffff81166122805760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c6564000000000000000000006044820152606401610705565b919050565b600054610100900460ff16610acc5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b600054610100900460ff1661237f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b610acc336117ce565b600054610100900460ff166124055760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b600054610100900460ff166124ac5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b6001609755565b82805482825590600052602060002090810192821561252d579160200282015b8281111561252d57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9091161782556020909201916001909101906124d3565b50612539929150612578565b5090565b82805482825590600052602060002090810192821561252d579160200282015b8281111561252d57825182559160200191906001019061255d565b5b808211156125395760008155600101612579565b60008083601f84011261259f57600080fd5b50813567ffffffffffffffff8111156125b757600080fd5b6020830191508360208260051b85010111156125d257600080fd5b9250929050565b600080600080606085870312156125ef57600080fd5b84359350602085013567ffffffffffffffff81111561260d57600080fd5b6126198782880161258d565b9598909750949560400135949350505050565b6020808252825182820181905260009190848201906040850190845b8181101561266457835183529284019291840191600101612648565b50909695505050505050565b803560ff8116811461228057600080fd5b6000806040838503121561269457600080fd5b823591506126a460208401612670565b90509250929050565b6000602082840312156126bf57600080fd5b5035919050565b600080600080608085870312156126dc57600080fd5b843593506126ec60208601612670565b93969395505050506040820135916060013590565b6000806000806060858703121561271757600080fd5b843567ffffffffffffffff81111561272e57600080fd5b61273a8782880161258d565b90989097506020870135966040013595509350505050565b6000806040838503121561276557600080fd5b50508035926020909101359150565b73ffffffffffffffffffffffffffffffffffffffff8116811461169457600080fd5b803561228081612774565b6000602082840312156127b357600080fd5b81356127be81612774565b9392505050565b6000602082840312156127d757600080fd5b6108cd82612670565b600080600080600060a086880312156127f857600080fd5b61280186612670565b945061280f60208701612670565b94979496505050506040830135926060810135926080909101359150565b60008060006060848603121561284257600080fd5b61284b84612670565b925061285960208501612670565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156128df576128df612869565b604052919050565b600067ffffffffffffffff82111561290157612901612869565b5060051b60200190565b600082601f83011261291c57600080fd5b8135602061293161292c836128e7565b612898565b82815260059290921b8401810191818101908684111561295057600080fd5b8286015b8481101561297457803561296781612774565b8352918301918301612954565b509695505050505050565b600082601f83011261299057600080fd5b813560206129a061292c836128e7565b82815260059290921b840181019181810190868411156129bf57600080fd5b8286015b84811015612974576129d481612670565b83529183019183016129c3565b600082601f8301126129f257600080fd5b813567ffffffffffffffff811115612a0c57612a0c612869565b612a3d60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612898565b818152846020838601011115612a5257600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600080610100898b031215612a8c57600080fd5b883567ffffffffffffffff80821115612aa457600080fd5b612ab08c838d0161290b565b995060208b0135915080821115612ac657600080fd5b612ad28c838d0161297f565b985060408b0135915080821115612ae857600080fd5b612af48c838d016129e1565b975060608b0135915080821115612b0a57600080fd5b50612b178b828c016129e1565b9550506080890135935060a0890135925060c08901359150612b3b60e08a01612796565b90509295985092959890939650565b801515811461169457600080fd5b600080600060408486031215612b6d57600080fd5b833567ffffffffffffffff811115612b8457600080fd5b612b908682870161258d565b9094509250506020840135612ba481612b4a565b809150509250925092565b600060208284031215612bc157600080fd5b5051919050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115612bfa57600080fd5b8260051b80836020870137939093016020019392505050565b848152836020820152606060408201526000612c33606083018486612bc8565b9695505050505050565b60006020808385031215612c5057600080fd5b825167ffffffffffffffff811115612c6757600080fd5b8301601f81018513612c7857600080fd5b8051612c8661292c826128e7565b81815260059190911b82018301908381019087831115612ca557600080fd5b928401925b82841015612cc357835182529284019290840190612caa565b979650505050505050565b848152606060208201526000612ce8606083018587612bc8565b905082604083015295945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b848152606060208201526000612d42606083018587612bc8565b9050821515604083015295945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156108d0576108d0612d55565b600181815b80851115612df057817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612dd657612dd6612d55565b80851615612de357918102915b93841c9390800290612d9c565b509250929050565b600082612e07575060016108d0565b81612e14575060006108d0565b8160018114612e2a5760028114612e3457612e50565b60019150506108d0565b60ff841115612e4557612e45612d55565b50506001821b6108d0565b5060208310610133831016604e8410600b8410161715612e73575081810a6108d0565b612e7d8383612d97565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612eaf57612eaf612d55565b029392505050565b60006108cd8383612df8565b600060ff821660ff8103612ed957612ed9612d55565b60010192915050565b6000815180845260005b81811015612f0857602081850181015186830182015201612eec565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b604081526000612f596040830185612ee2565b8281036020840152612f6b8185612ee2565b95945050505050565b600060208284031215612f8657600080fd5b81516127be81612b4a565b80820281158282048414176108d0576108d0612d5556fea2646970667358221220d17bf4b8931a533607e3294e3a4971a80ffd5363c9d61e6a188595e8c121ffa364736f6c63430008110033", + "deployedBytecode": "0x6080604052600436106101c25760003560e01c80638456cb59116100f7578063b28cb6dc11610095578063e6ab280611610064578063e6ab2806146104d7578063ef0a712f146104f7578063f2fad2b614610517578063f2fde38b1461053757600080fd5b8063b28cb6dc14610492578063c4db7fa0146104a5578063d46300fd146104ad578063e25aa5fa146104c257600080fd5b80638da5cb5b116100d15780638da5cb5b14610414578063916955861461043f57806391ceb3eb14610452578063a95b089f1461047257600080fd5b80638456cb59146103d957806384cdd9bc146103ee5780638beb60b61461040157600080fd5b80634d49e87d116101645780635fd65f0f1161013e5780635fd65f0f146102bd57806366c0bd241461034d578063715018a61461037f57806382b866001461039457600080fd5b80634d49e87d14610274578063593d132c146102875780635c975abb1461029a57600080fd5b8063342a87a1116101a0578063342a87a11461021957806334e19907146102395780633e3a15601461024c5780633f4ba83a1461025f57600080fd5b80630419b45a146101c75780630ba81959146101d157806331cd52b0146101f9575b600080fd5b6101cf610557565b005b3480156101dd57600080fd5b506101e661061f565b6040519081526020015b60405180910390f35b61020c6102073660046125d9565b6106b5565b6040516101f0919061262c565b34801561022557600080fd5b506101e6610234366004612681565b61082d565b6101cf6102473660046126ad565b6108d6565b6101e661025a3660046126c6565b610965565b34801561026b57600080fd5b506101cf610abc565b6101e6610282366004612701565b610ace565b6101cf610295366004612752565b610bd7565b3480156102a657600080fd5b5060655460ff1660405190151581526020016101f0565b3480156102c957600080fd5b5060c95460ca5460cb5460cc5460cd5460ce5460cf546103029695949392919073ffffffffffffffffffffffffffffffffffffffff1687565b604080519788526020880196909652948601939093526060850191909152608084015260a083015273ffffffffffffffffffffffffffffffffffffffff1660c082015260e0016101f0565b34801561035957600080fd5b5061036d6103683660046127a1565b610c6d565b60405160ff90911681526020016101f0565b34801561038b57600080fd5b506101cf610d07565b3480156103a057600080fd5b506103b46103af3660046127c5565b610d19565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101f0565b3480156103e557600080fd5b506101cf610daf565b6101e66103fc366004612701565b610dbf565b6101cf61040f3660046126ad565b610ec8565b34801561042057600080fd5b5060335473ffffffffffffffffffffffffffffffffffffffff166103b4565b6101e661044d3660046127e0565b610f28565b34801561045e57600080fd5b506101e661046d3660046127c5565b611096565b34801561047e57600080fd5b506101e661048d36600461282d565b611116565b6101cf6104a0366004612a6f565b6111c7565b6101cf61134f565b3480156104b957600080fd5b506101e66113a8565b3480156104ce57600080fd5b506101e66113fc565b3480156104e357600080fd5b506101e66104f2366004612b58565b611450565b34801561050357600080fd5b506101e66105123660046126ad565b6114aa565b34801561052357600080fd5b5061020c6105323660046126ad565b611541565b34801561054357600080fd5b506101cf6105523660046127a1565b6115fa565b61055f611697565b73__$62e764fb90da77cece56b4de77dad8e9ad$__63fe7cb1c060c961059a60335473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b168152600481019290925273ffffffffffffffffffffffffffffffffffffffff1660248201526044015b60006040518083038186803b15801561060557600080fd5b505af4158015610619573d6000803e3d6000fd5b50505050565b6040517fc4a241f700000000000000000000000000000000000000000000000000000000815260c9600482015260009073__$ae7faf633ebe56adae0bfb03bb6572d07a$__9063c4a241f7906024015b602060405180830381865af415801561068c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b09190612baf565b905090565b606060026097540361070e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260975581428110156107645760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517ffa76ee2a00000000000000000000000000000000000000000000000000000000815273__$62e764fb90da77cece56b4de77dad8e9ad$__9063fa76ee2a906107bb9060c9908a908a908a90600401612c13565b600060405180830381865af41580156107d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261081e9190810190612c3d565b60016097559695505050505050565b6040517f1a535da500000000000000000000000000000000000000000000000000000000815260c960048201526024810183905260ff8216604482015260009073__$62e764fb90da77cece56b4de77dad8e9ad$__90631a535da590606401602060405180830381865af41580156108a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108cd9190612baf565b90505b92915050565b6108de611697565b6040517f05f7ec2100000000000000000000000000000000000000000000000000000000815260c960048201526024810182905273__$62e764fb90da77cece56b4de77dad8e9ad$__906305f7ec21906044015b60006040518083038186803b15801561094a57600080fd5b505af415801561095e573d6000803e3d6000fd5b5050505050565b60006002609754036109b95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b60026097556109c66116fe565b8180421115610a175760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f711cd33000000000000000000000000000000000000000000000000000000000815260c960048201526024810187905260ff861660448201526064810185905273__$62e764fb90da77cece56b4de77dad8e9ad$__9063711cd330906084015b602060405180830381865af4158015610a98573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e9190612baf565b610ac4611697565b610acc611751565b565b6000600260975403610b225760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610b2f6116fe565b8180421115610b805760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f041894b000000000000000000000000000000000000000000000000000000000815273__$62e764fb90da77cece56b4de77dad8e9ad$__9063041894b090610a7b9060c9908a908a908a90600401612cce565b610bdf611697565b6040517f858490d300000000000000000000000000000000000000000000000000000000815260c96004820152602481018390526044810182905273__$ae7faf633ebe56adae0bfb03bb6572d07a$__9063858490d39060640160006040518083038186803b158015610c5157600080fd5b505af4158015610c65573d6000803e3d6000fd5b505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260d36020526040812054909160ff90911690610ca482610d19565b73ffffffffffffffffffffffffffffffffffffffff16146108d05760405162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f742065786973740000000000000000000000006044820152606401610705565b610d0f611697565b610acc60006117ce565b60d05460009060ff831610610d705760405162461bcd60e51b815260206004820152600c60248201527f4f7574206f662072616e676500000000000000000000000000000000000000006044820152606401610705565b60d0805460ff8416908110610d8757610d87612cf9565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1692915050565b610db7611697565b610acc611845565b6000600260975403610e135760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610e206116fe565b8180421115610e715760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517f4540fb7f00000000000000000000000000000000000000000000000000000000815273__$62e764fb90da77cece56b4de77dad8e9ad$__90634540fb7f90610a7b9060c9908a908a908a90600401612cce565b610ed0611697565b6040517fa125d92400000000000000000000000000000000000000000000000000000000815260c960048201526024810182905273__$62e764fb90da77cece56b4de77dad8e9ad$__9063a125d92490604401610932565b6000600260975403610f7c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610705565b6002609755610f896116fe565b8180421115610fda5760405162461bcd60e51b815260206004820152601060248201527f446561646c696e65206e6f74206d6574000000000000000000000000000000006044820152606401610705565b6040517facf9147800000000000000000000000000000000000000000000000000000000815260c9600482015260ff808916602483015287166044820152606481018690526084810185905273__$62e764fb90da77cece56b4de77dad8e9ad$__9063acf914789060a401602060405180830381865af4158015611062573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110869190612baf565b6001609755979650505050505050565b60d05460009060ff8316106110ed5760405162461bcd60e51b815260206004820152601260248201527f496e646578206f7574206f662072616e676500000000000000000000000000006044820152606401610705565b60d2805460ff841690811061110457611104612cf9565b90600052602060002001549050919050565b6040517f39e43af200000000000000000000000000000000000000000000000000000000815260c9600482015260ff8085166024830152831660448201526064810182905260009073__$62e764fb90da77cece56b4de77dad8e9ad$__906339e43af2906084015b602060405180830381865af415801561119b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bf9190612baf565b949350505050565b600054610100900460ff16158080156111e75750600054600160ff909116105b806112015750303b158015611201575060005460ff166001145b6112735760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610705565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156112d157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6112e189898989898989896118a0565b801561134457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b611357611697565b6040517fd3a605a500000000000000000000000000000000000000000000000000000000815260c9600482015273__$ae7faf633ebe56adae0bfb03bb6572d07a$__9063d3a605a5906024016105ed565b6040517f1c103df000000000000000000000000000000000000000000000000000000000815260c9600482015260009073__$ae7faf633ebe56adae0bfb03bb6572d07a$__90631c103df09060240161066f565b6040517f98a20a3e00000000000000000000000000000000000000000000000000000000815260c9600482015260009073__$62e764fb90da77cece56b4de77dad8e9ad$__906398a20a3e9060240161066f565b6040517f6972fae800000000000000000000000000000000000000000000000000000000815260009073__$62e764fb90da77cece56b4de77dad8e9ad$__90636972fae89061117e9060c990889088908890600401612d28565b6040517fcbc7f8dd00000000000000000000000000000000000000000000000000000000815260c960048201526024810182905260009073__$62e764fb90da77cece56b4de77dad8e9ad$__9063cbc7f8dd90604401602060405180830381865af415801561151d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d09190612baf565b6040517f8424905f00000000000000000000000000000000000000000000000000000000815260c960048201526024810182905260609073__$62e764fb90da77cece56b4de77dad8e9ad$__90638424905f90604401600060405180830381865af41580156115b4573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526108d09190810190612c3d565b611602611697565b73ffffffffffffffffffffffffffffffffffffffff811661168b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610705565b611694816117ce565b50565b60335473ffffffffffffffffffffffffffffffffffffffff163314610acc5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610705565b60655460ff1615610acc5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610705565b611759612051565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61184d6116fe565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117a43390565b600054610100900460ff1661191d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b6119256120a3565b61192d612138565b600188511161197e5760405162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203c3d2031000000000000006044820152606401610705565b6020885111156119d05760405162461bcd60e51b815260206004820152601960248201527f5f706f6f6c6564546f6b656e732e6c656e677468203e203332000000000000006044820152606401610705565b8651885114611a215760405162461bcd60e51b815260206004820152601f60248201527f5f706f6f6c6564546f6b656e7320646563696d616c73206d69736d61746368006044820152606401610705565b6000875167ffffffffffffffff811115611a3d57611a3d612869565b604051908082528060200260200182016040528015611a66578160200160208202803683370190505b50905060005b89518160ff161015611d765760ff811615611b895760d360008b8360ff1681518110611a9a57611a9a612cf9565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff1682528101919091526040016000205460ff16158015611b3d5750898160ff1681518110611aeb57611aeb612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff168a600081518110611b1c57611b1c612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614155b611b895760405162461bcd60e51b815260206004820152601060248201527f4475706c696361746520746f6b656e73000000000000000000000000000000006044820152606401610705565b600073ffffffffffffffffffffffffffffffffffffffff168a8260ff1681518110611bb657611bb6612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1603611c215760405162461bcd60e51b815260206004820152601d60248201527f546865203020616464726573732069736e277420616e204552432d32300000006044820152606401610705565b601260ff16898260ff1681518110611c3b57611c3b612cf9565b602002602001015160ff161115611c945760405162461bcd60e51b815260206004820152601a60248201527f546f6b656e20646563696d616c732065786365656473206d61780000000000006044820152606401610705565b888160ff1681518110611ca957611ca9612cf9565b602002602001015160ff16601260ff16611cc39190612d84565b611cce90600a612eb7565b828260ff1681518110611ce357611ce3612cf9565b6020026020010181815250508060d360008c8460ff1681518110611d0957611d09612cf9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055508080611d6e90612ec3565b915050611a6c565b50620f42408510611dc95760405162461bcd60e51b815260206004820152601260248201527f5f612065786365656473206d6178696d756d00000000000000000000000000006044820152606401610705565b6305f5e1008410611e1c5760405162461bcd60e51b815260206004820152601460248201527f5f6665652065786365656473206d6178696d756d0000000000000000000000006044820152606401610705565b6402540be4008310611e705760405162461bcd60e51b815260206004820152601960248201527f5f61646d696e4665652065786365656473206d6178696d756d000000000000006044820152606401610705565b6000611e7b836121bd565b6040517f4cd88b7600000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff821690634cd88b7690611ed2908b908b90600401612f46565b6020604051808303816000875af1158015611ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f159190612f74565b611f615760405162461bcd60e51b815260206004820152601c60248201527f636f756c64206e6f7420696e6974206c70546f6b656e20636c6f6e65000000006044820152606401610705565b60cf80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790558951611fb49060d09060208d01906124b3565b508151611fc89060d190602085019061253d565b50895167ffffffffffffffff811115611fe357611fe3612869565b60405190808252806020026020018201604052801561200c578160200160208202803683370190505b5080516120219160d29160209091019061253d565b5061202d606487612f91565b60c95561203b606487612f91565b60ca5550505060cd9190915560ce555050505050565b60655460ff16610acc5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610705565b600054610100900460ff166121205760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b612128612285565b612130612302565b610acc612388565b600054610100900460ff166121b55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b610acc61242f565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f091505073ffffffffffffffffffffffffffffffffffffffff81166122805760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c6564000000000000000000006044820152606401610705565b919050565b600054610100900460ff16610acc5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b600054610100900460ff1661237f5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b610acc336117ce565b600054610100900460ff166124055760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b606580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b600054610100900460ff166124ac5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610705565b6001609755565b82805482825590600052602060002090810192821561252d579160200282015b8281111561252d57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9091161782556020909201916001909101906124d3565b50612539929150612578565b5090565b82805482825590600052602060002090810192821561252d579160200282015b8281111561252d57825182559160200191906001019061255d565b5b808211156125395760008155600101612579565b60008083601f84011261259f57600080fd5b50813567ffffffffffffffff8111156125b757600080fd5b6020830191508360208260051b85010111156125d257600080fd5b9250929050565b600080600080606085870312156125ef57600080fd5b84359350602085013567ffffffffffffffff81111561260d57600080fd5b6126198782880161258d565b9598909750949560400135949350505050565b6020808252825182820181905260009190848201906040850190845b8181101561266457835183529284019291840191600101612648565b50909695505050505050565b803560ff8116811461228057600080fd5b6000806040838503121561269457600080fd5b823591506126a460208401612670565b90509250929050565b6000602082840312156126bf57600080fd5b5035919050565b600080600080608085870312156126dc57600080fd5b843593506126ec60208601612670565b93969395505050506040820135916060013590565b6000806000806060858703121561271757600080fd5b843567ffffffffffffffff81111561272e57600080fd5b61273a8782880161258d565b90989097506020870135966040013595509350505050565b6000806040838503121561276557600080fd5b50508035926020909101359150565b73ffffffffffffffffffffffffffffffffffffffff8116811461169457600080fd5b803561228081612774565b6000602082840312156127b357600080fd5b81356127be81612774565b9392505050565b6000602082840312156127d757600080fd5b6108cd82612670565b600080600080600060a086880312156127f857600080fd5b61280186612670565b945061280f60208701612670565b94979496505050506040830135926060810135926080909101359150565b60008060006060848603121561284257600080fd5b61284b84612670565b925061285960208501612670565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156128df576128df612869565b604052919050565b600067ffffffffffffffff82111561290157612901612869565b5060051b60200190565b600082601f83011261291c57600080fd5b8135602061293161292c836128e7565b612898565b82815260059290921b8401810191818101908684111561295057600080fd5b8286015b8481101561297457803561296781612774565b8352918301918301612954565b509695505050505050565b600082601f83011261299057600080fd5b813560206129a061292c836128e7565b82815260059290921b840181019181810190868411156129bf57600080fd5b8286015b84811015612974576129d481612670565b83529183019183016129c3565b600082601f8301126129f257600080fd5b813567ffffffffffffffff811115612a0c57612a0c612869565b612a3d60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612898565b818152846020838601011115612a5257600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600080610100898b031215612a8c57600080fd5b883567ffffffffffffffff80821115612aa457600080fd5b612ab08c838d0161290b565b995060208b0135915080821115612ac657600080fd5b612ad28c838d0161297f565b985060408b0135915080821115612ae857600080fd5b612af48c838d016129e1565b975060608b0135915080821115612b0a57600080fd5b50612b178b828c016129e1565b9550506080890135935060a0890135925060c08901359150612b3b60e08a01612796565b90509295985092959890939650565b801515811461169457600080fd5b600080600060408486031215612b6d57600080fd5b833567ffffffffffffffff811115612b8457600080fd5b612b908682870161258d565b9094509250506020840135612ba481612b4a565b809150509250925092565b600060208284031215612bc157600080fd5b5051919050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115612bfa57600080fd5b8260051b80836020870137939093016020019392505050565b848152836020820152606060408201526000612c33606083018486612bc8565b9695505050505050565b60006020808385031215612c5057600080fd5b825167ffffffffffffffff811115612c6757600080fd5b8301601f81018513612c7857600080fd5b8051612c8661292c826128e7565b81815260059190911b82018301908381019087831115612ca557600080fd5b928401925b82841015612cc357835182529284019290840190612caa565b979650505050505050565b848152606060208201526000612ce8606083018587612bc8565b905082604083015295945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b848152606060208201526000612d42606083018587612bc8565b9050821515604083015295945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156108d0576108d0612d55565b600181815b80851115612df057817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612dd657612dd6612d55565b80851615612de357918102915b93841c9390800290612d9c565b509250929050565b600082612e07575060016108d0565b81612e14575060006108d0565b8160018114612e2a5760028114612e3457612e50565b60019150506108d0565b60ff841115612e4557612e45612d55565b50506001821b6108d0565b5060208310610133831016604e8410600b8410161715612e73575081810a6108d0565b612e7d8383612d97565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612eaf57612eaf612d55565b029392505050565b60006108cd8383612df8565b600060ff821660ff8103612ed957612ed9612d55565b60010192915050565b6000815180845260005b81811015612f0857602081850181015186830182015201612eec565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b604081526000612f596040830185612ee2565b8281036020840152612f6b8185612ee2565b95945050505050565b600060208284031215612f8657600080fd5b81516127be81612b4a565b80820281158282048414176108d0576108d0612d5556fea2646970667358221220d17bf4b8931a533607e3294e3a4971a80ffd5363c9d61e6a188595e8c121ffa364736f6c63430008110033", + "libraries": { + "SwapUtilsV2": "0x4a5208f83a17e030a18830521e4064e80728c4fc", + "AmplificationUtilsV2": "0xFdA5D2ad8b6d3884AbB799DA66f57175E8706941" + }, + "devdoc": { + "details": "Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's deployment size.", + "kind": "dev", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "deadline": "latest timestamp to accept this transaction", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation" + }, + "returns": { + "_0": "amount of LP token user minted and received" + } + }, + "calculateRemoveLiquidity(uint256)": { + "params": { + "amount": "the amount of LP tokens that would be burned on withdrawal" + }, + "returns": { + "_0": "array of token balances that the user will receive" + } + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "params": { + "tokenAmount": "the amount of LP token to burn", + "tokenIndex": "index of which token will be withdrawn" + }, + "returns": { + "availableTokenAmount": "calculated amount of underlying token available to withdraw" + } + }, + "calculateSwap(uint8,uint8,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of tokens the user will receive" + } + }, + "calculateTokenAmount(uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal" + }, + "returns": { + "_0": "token amount the user will receive" + } + }, + "getA()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter" + } + }, + "getAPrecise()": { + "details": "See the StableSwap paper for details", + "returns": { + "_0": "A parameter in its raw precision form" + } + }, + "getAdminBalance(uint256)": { + "params": { + "index": "Index of the pooled token" + }, + "returns": { + "_0": "admin's token balance in the token's precision" + } + }, + "getToken(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "address of the token at given index" + } + }, + "getTokenBalance(uint8)": { + "params": { + "index": "the index of the token" + }, + "returns": { + "_0": "current balance of the pooled token at given index with token's native precision" + } + }, + "getTokenIndex(address)": { + "params": { + "tokenAddress": "address of the token" + }, + "returns": { + "_0": "the index of the given token address" + } + }, + "getVirtualPrice()": { + "returns": { + "_0": "the virtual price, scaled to the POOL_PRECISION_DECIMALS" + } + }, + "initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)": { + "params": { + "_a": "the amplification coefficient * n * (n - 1). See the StableSwap paper for details", + "_adminFee": "default adminFee to be initialized with", + "_fee": "default swap fee to be initialized with", + "_pooledTokens": "an array of ERC20s this pool will accept", + "decimals": "the decimals to use for each pooled token, eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS", + "lpTokenName": "the long-form name of the token to be deployed", + "lpTokenSymbol": "the short symbol for the token to be deployed", + "lpTokenTargetAddress": "the address of an existing LPToken contract to use as a target" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "rampA(uint256,uint256)": { + "params": { + "futureA": "the new A to ramp towards", + "futureTime": "timestamp when the new A should be reached" + } + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "details": "Liquidity can always be removed, even when the pool is paused.", + "params": { + "amount": "the amount of LP tokens to burn", + "deadline": "latest timestamp to accept this transaction", + "minAmounts": "the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation" + }, + "returns": { + "_0": "amounts of tokens user received" + } + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "deadline": "latest timestamp to accept this transaction", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation." + }, + "returns": { + "_0": "amount of LP tokens burned" + } + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "minAmount": "the minimum amount to withdraw, otherwise revert", + "tokenAmount": "the amount of the token you want to receive", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount of chosen token user received" + } + }, + "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." + }, + "setAdminFee(uint256)": { + "params": { + "newAdminFee": "new admin fee to be applied on future transactions" + } + }, + "setSwapFee(uint256)": { + "params": { + "newSwapFee": "new swap fee to be applied on future transactions" + } + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "params": { + "deadline": "latest timestamp to accept this transaction", + "dx": "the amount of tokens the user wants to swap from", + "minDy": "the min amount the user would like to receive, or revert.", + "tokenIndexFrom": "the token the user wants to swap from", + "tokenIndexTo": "the token the user wants to swap to" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "Swap - A StableSwap implementation in solidity.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(uint256[],uint256,uint256)": { + "notice": "Add liquidity to the pool with the given amounts of tokens" + }, + "calculateRemoveLiquidity(uint256)": { + "notice": "A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens" + }, + "calculateRemoveLiquidityOneToken(uint256,uint8)": { + "notice": "Calculate the amount of underlying token available to withdraw when withdrawing via only single token" + }, + "calculateSwap(uint8,uint8,uint256)": { + "notice": "Calculate amount of tokens you receive on swap" + }, + "calculateTokenAmount(uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running" + }, + "getA()": { + "notice": "Return A, the amplification coefficient * n * (n - 1)" + }, + "getAPrecise()": { + "notice": "Return A in its raw precision form" + }, + "getAdminBalance(uint256)": { + "notice": "This function reads the accumulated amount of admin fees of the token with given index" + }, + "getToken(uint8)": { + "notice": "Return address of the pooled token at given index. Reverts if tokenIndex is out of range." + }, + "getTokenBalance(uint8)": { + "notice": "Return current balance of the pooled token at given index" + }, + "getTokenIndex(address)": { + "notice": "Return the index of the given token address. Reverts if no matching token is found." + }, + "getVirtualPrice()": { + "notice": "Get the virtual price, to help calculate profit" + }, + "initialize(address[],uint8[],string,string,uint256,uint256,uint256,address)": { + "notice": "Initializes this Swap contract with the given parameters. This will also clone a LPToken contract that represents users' LP positions. The owner of LPToken will be this contract - which means only this contract is allowed to mint/burn tokens." + }, + "pause()": { + "notice": "Pause the contract. Revert if already paused." + }, + "rampA(uint256,uint256)": { + "notice": "Start ramping up or down A parameter towards given futureA and futureTime Checks if the change is too rapid, and commits the new A value only when it falls under the limit range." + }, + "removeLiquidity(uint256,uint256[],uint256)": { + "notice": "Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityImbalance(uint256[],uint256,uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "removeLiquidityOneToken(uint256,uint8,uint256,uint256)": { + "notice": "Remove liquidity from the pool all in one token. Withdraw fee that decays linearly over period of 4 weeks since last deposit will apply." + }, + "setAdminFee(uint256)": { + "notice": "Update the admin fee. Admin fee takes portion of the swap fee." + }, + "setSwapFee(uint256)": { + "notice": "Update the swap fee to be applied on swaps" + }, + "stopRampA()": { + "notice": "Stop ramping A immediately. Reverts if ramp A is already stopped." + }, + "swap(uint8,uint8,uint256,uint256,uint256)": { + "notice": "Swap two tokens using this pool" + }, + "unpause()": { + "notice": "Unpause the contract. Revert if already unpaused." + }, + "withdrawAdminFees()": { + "notice": "Withdraw all admin fees to the contract owner" + } + }, + "notice": "This contract is responsible for custody of closely pegged assets (eg. group of stablecoins) and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens in desired ratios for an exchange of the pool token that represents their share of the pool. Users can burn pool tokens and withdraw their share of token(s). Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets distributed to the LPs. In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which stops the ratio of the tokens in the pool from changing. Users can always withdraw their tokens via multi-asset withdraws.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1654, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 1657, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 3046, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 1526, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 1646, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1819, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool" + }, + { + "astId": 1924, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 1939, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "_status", + "offset": 0, + "slot": "151", + "type": "t_uint256" + }, + { + "astId": 1983, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 6670, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "swapStorage", + "offset": 0, + "slot": "201", + "type": "t_struct(Swap)3865_storage" + }, + { + "astId": 6674, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "tokenIndexes", + "offset": 0, + "slot": "211", + "type": "t_mapping(t_address,t_uint8)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_contract(IERC20)856)dyn_storage": { + "base": "t_contract(IERC20)856", + "encoding": "dynamic_array", + "label": "contract IERC20[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_array(t_uint256)dyn_storage": { + "base": "t_uint256", + "encoding": "dynamic_array", + "label": "uint256[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)856": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(LPTokenV2)3463": { + "encoding": "inplace", + "label": "contract LPTokenV2", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint8)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint8)", + "numberOfBytes": "32", + "value": "t_uint8" + }, + "t_struct(Swap)3865_storage": { + "encoding": "inplace", + "label": "struct SwapUtilsV2.Swap", + "members": [ + { + "astId": 3841, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "initialA", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 3843, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "futureA", + "offset": 0, + "slot": "1", + "type": "t_uint256" + }, + { + "astId": 3845, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "initialATime", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 3847, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "futureATime", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 3849, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "swapFee", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 3851, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "adminFee", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 3854, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "lpToken", + "offset": 0, + "slot": "6", + "type": "t_contract(LPTokenV2)3463" + }, + { + "astId": 3858, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "pooledTokens", + "offset": 0, + "slot": "7", + "type": "t_array(t_contract(IERC20)856)dyn_storage" + }, + { + "astId": 3861, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "tokenPrecisionMultipliers", + "offset": 0, + "slot": "8", + "type": "t_array(t_uint256)dyn_storage" + }, + { + "astId": 3864, + "contract": "contracts/SwapV2.sol:SwapV2", + "label": "balances", + "offset": 0, + "slot": "9", + "type": "t_array(t_uint256)dyn_storage" + } + ], + "numberOfBytes": "320" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} diff --git a/deployments/base_testnet/SaddleDummyPoolLPToken.json b/deployments/base_testnet/SaddleDummyPoolLPToken.json new file mode 100644 index 00000000..29e3600a --- /dev/null +++ b/deployments/base_testnet/SaddleDummyPoolLPToken.json @@ -0,0 +1,414 @@ +{ + "address": "0x8CC3FBEd8fBFa094936b14BD99d34e991cFd1af3", + "abi": [ + { + "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": 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": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "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": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "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": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "name": "initialize", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "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" + } + ], + "numDeployments": 1 +} diff --git a/deployments/base_testnet/SwapUtilsV2.json b/deployments/base_testnet/SwapUtilsV2.json new file mode 100644 index 00000000..d83e9274 --- /dev/null +++ b/deployments/base_testnet/SwapUtilsV2.json @@ -0,0 +1,456 @@ +{ + "address": "0x4a5208f83a17e030a18830521e4064e80728c4fc", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "AddLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newAdminFee", + "type": "uint256" + } + ], + "name": "NewAdminFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newSwapFee", + "type": "uint256" + } + ], + "name": "NewSwapFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "tokenAmounts", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "fees", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "invariant", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + } + ], + "name": "RemoveLiquidityImbalance", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lpTokenSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "boughtId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + } + ], + "name": "RemoveLiquidityOne", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "buyer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensBought", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "soldId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "boughtId", + "type": "uint128" + } + ], + "name": "TokenSwap", + "type": "event" + }, + { + "inputs": [], + "name": "MAX_ADMIN_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_SWAP_FEE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL_PRECISION_DECIMALS", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x5c82d310eacb7508d863ec60ed1b32897c72d729780a7cf7398579392903984b", + "receipt": { + "to": null, + "from": "0x5bdb37d0ddea3a90f233c7b7f6b9394b6b2eef34", + "contractAddress": "0x4a5208f83a17e030a18830521e4064e80728c4fc", + "transactionIndex": "0x2", + "gasUsed": "0x3c53ce", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x2663c7788d50dea7c0ee30f214c8cb52de00d81ebad8f34efee733863dc36e5f", + "transactionHash": "0x5c82d310eacb7508d863ec60ed1b32897c72d729780a7cf7398579392903984b", + "logs": [], + "blockNumber": "0x28b90a", + "cumulativeGasUsed": "0x3d1d4d", + "status": "0x1" + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "faeaaf1f06e012c3200d7f368f424bd7", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newAdminFee\",\"type\":\"uint256\"}],\"name\":\"NewAdminFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newSwapFee\",\"type\":\"uint256\"}],\"name\":\"NewSwapFee\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"tokenAmounts\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"fees\",\"type\":\"uint256[]\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"invariant\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityImbalance\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lpTokenSupply\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"boughtId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidityOne\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensSold\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokensBought\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"soldId\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"boughtId\",\"type\":\"uint128\"}],\"name\":\"TokenSwap\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_ADMIN_FEE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_SWAP_FEE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"POOL_PRECISION_DECIMALS\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contracts relying on this library must initialize SwapUtils.Swap struct then use this library for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins. Admin functions should be protected within contracts using this library.\",\"kind\":\"dev\",\"methods\":{\"addLiquidity(SwapUtilsV2.Swap storage,uint256[],uint256)\":{\"params\":{\"amounts\":\"the amounts of each token to add, in their native precision\",\"minToMint\":\"the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\",\"self\":\"Swap struct to read from and write to\"},\"returns\":{\"_0\":\"amount of LP token user received\"}},\"calculateRemoveLiquidity(SwapUtilsV2.Swap storage,uint256)\":{\"params\":{\"amount\":\"the amount of LP tokens that would to be burned on withdrawal\"},\"returns\":{\"_0\":\"array of amounts of tokens user will receive\"}},\"calculateSwap(SwapUtilsV2.Swap storage,uint8,uint8,uint256)\":{\"params\":{\"dx\":\"the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"self\":\"Swap struct to read from\",\"tokenIndexFrom\":\"the token to sell\",\"tokenIndexTo\":\"the token to buy\"},\"returns\":{\"dy\":\"the number of tokens the user will get\"}},\"calculateTokenAmount(SwapUtilsV2.Swap storage,uint256[],bool)\":{\"details\":\"This shouldn't be used outside frontends for user estimates.\",\"params\":{\"amounts\":\"an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.\",\"deposit\":\"whether this is a deposit or a withdrawal\",\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"if deposit was true, total amount of lp token that will be minted and if deposit was false, total amount of lp token that will be burned\"}},\"calculateWithdrawOneToken(SwapUtilsV2.Swap storage,uint256,uint8)\":{\"params\":{\"self\":\"Swap struct to read from\",\"tokenAmount\":\"the amount to withdraw in the pool's precision\",\"tokenIndex\":\"which token will be withdrawn\"},\"returns\":{\"_0\":\"the amount of token user will receive\"}},\"getAdminBalance(SwapUtilsV2.Swap storage,uint256)\":{\"params\":{\"index\":\"Index of the pooled token\",\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"admin balance in the token's precision\"}},\"getVirtualPrice(SwapUtilsV2.Swap storage)\":{\"params\":{\"self\":\"Swap struct to read from\"},\"returns\":{\"_0\":\"the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\"}},\"removeLiquidity(SwapUtilsV2.Swap storage,uint256,uint256[])\":{\"details\":\"Liquidity can always be removed, even when the pool is paused.\",\"params\":{\"amount\":\"the amount of LP tokens to burn\",\"minAmounts\":\"the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation\",\"self\":\"Swap struct to read from and write to\"},\"returns\":{\"_0\":\"amounts of tokens the user received\"}},\"removeLiquidityImbalance(SwapUtilsV2.Swap storage,uint256[],uint256)\":{\"params\":{\"amounts\":\"how much of each token to withdraw\",\"maxBurnAmount\":\"the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.\",\"self\":\"Swap struct to read from and write to\"},\"returns\":{\"_0\":\"actual amount of LP tokens burned in the withdrawal\"}},\"removeLiquidityOneToken(SwapUtilsV2.Swap storage,uint256,uint8,uint256)\":{\"params\":{\"minAmount\":\"the minimum amount to withdraw, otherwise revert\",\"self\":\"Swap struct to read from and write to\",\"tokenAmount\":\"the amount of the lp tokens to burn\",\"tokenIndex\":\"the index of the token you want to receive\"},\"returns\":{\"_0\":\"amount chosen token that user received\"}},\"setAdminFee(SwapUtilsV2.Swap storage,uint256)\":{\"details\":\"adminFee cannot be higher than 100% of the swap fee\",\"params\":{\"newAdminFee\":\"new admin fee to be applied on future transactions\",\"self\":\"Swap struct to update\"}},\"setSwapFee(SwapUtilsV2.Swap storage,uint256)\":{\"details\":\"fee cannot be higher than 1% of each swap\",\"params\":{\"newSwapFee\":\"new swap fee to be applied on future transactions\",\"self\":\"Swap struct to update\"}},\"swap(SwapUtilsV2.Swap storage,uint8,uint8,uint256,uint256)\":{\"params\":{\"dx\":\"the amount of tokens the user wants to sell\",\"minDy\":\"the min amount the user would like to receive, or revert.\",\"self\":\"Swap struct to read from and write to\",\"tokenIndexFrom\":\"the token the user wants to sell\",\"tokenIndexTo\":\"the token the user wants to buy\"},\"returns\":{\"_0\":\"amount of token user received on swap\"}},\"withdrawAdminFees(SwapUtilsV2.Swap storage,address)\":{\"params\":{\"self\":\"Swap struct to withdraw fees from\",\"to\":\"Address to send the fees to\"}}},\"title\":\"SwapUtils library\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(SwapUtilsV2.Swap storage,uint256[],uint256)\":{\"notice\":\"Add liquidity to the pool\"},\"calculateRemoveLiquidity(SwapUtilsV2.Swap storage,uint256)\":{\"notice\":\"A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens\"},\"calculateSwap(SwapUtilsV2.Swap storage,uint8,uint8,uint256)\":{\"notice\":\"Externally calculates a swap between two tokens.\"},\"calculateTokenAmount(SwapUtilsV2.Swap storage,uint256[],bool)\":{\"notice\":\"A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \\\"min\\\" parameters on calls to fight front-running\"},\"calculateWithdrawOneToken(SwapUtilsV2.Swap storage,uint256,uint8)\":{\"notice\":\"Calculate the dy, the amount of selected token that user receives and the fee of withdrawing in one token\"},\"getAdminBalance(SwapUtilsV2.Swap storage,uint256)\":{\"notice\":\"return accumulated amount of admin fees of the token with given index\"},\"getVirtualPrice(SwapUtilsV2.Swap storage)\":{\"notice\":\"Get the virtual price, to help calculate profit\"},\"removeLiquidity(SwapUtilsV2.Swap storage,uint256,uint256[])\":{\"notice\":\"Burn LP tokens to remove liquidity from the pool.\"},\"removeLiquidityImbalance(SwapUtilsV2.Swap storage,uint256[],uint256)\":{\"notice\":\"Remove liquidity from the pool, weighted differently than the pool's current balances.\"},\"removeLiquidityOneToken(SwapUtilsV2.Swap storage,uint256,uint8,uint256)\":{\"notice\":\"Remove liquidity from the pool all in one token.\"},\"setAdminFee(SwapUtilsV2.Swap storage,uint256)\":{\"notice\":\"Sets the admin fee\"},\"setSwapFee(SwapUtilsV2.Swap storage,uint256)\":{\"notice\":\"update the swap fee\"},\"swap(SwapUtilsV2.Swap storage,uint8,uint8,uint256,uint256)\":{\"notice\":\"swap two tokens in the pool\"},\"withdrawAdminFees(SwapUtilsV2.Swap storage,address)\":{\"notice\":\"withdraw all admin fees to a given address\"}},\"notice\":\"A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/SwapUtilsV2.sol\":\"SwapUtilsV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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\":\"0x24b04b8aacaaf1a4a0719117b29c9c3647b1f479c5ac2a60f5ff1bb6d839c238\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-4.7.3/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\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 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 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\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/ERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20Upgradeable.sol\\\";\\nimport \\\"./extensions/IERC20MetadataUpgradeable.sol\\\";\\nimport \\\"../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\\n __ERC20_init_unchained(name_, symbol_);\\n }\\n\\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\\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 }\\n _balances[to] += amount;\\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 _balances[account] += amount;\\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 }\\n _totalSupply -= amount;\\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 /**\\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[45] private __gap;\\n}\\n\",\"keccak256\":\"0x7c7ac0bc6c340a7f320524b9a4b4b079ee9da3c51258080d4bab237f329a427c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \\\"../ERC20Upgradeable.sol\\\";\\nimport \\\"../../../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\\n function __ERC20Burnable_init() internal onlyInitializing {\\n }\\n\\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev Destroys `amount` tokens from the caller.\\n *\\n * See {ERC20-_burn}.\\n */\\n function burn(uint256 amount) public virtual {\\n _burn(_msgSender(), amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\\n * allowance.\\n *\\n * See {ERC20-_burn} and {ERC20-allowance}.\\n *\\n * Requirements:\\n *\\n * - the caller must have allowance for ``accounts``'s tokens of at least\\n * `amount`.\\n */\\n function burnFrom(address account, uint256 amount) public virtual {\\n _spendAllowance(account, _msgSender(), amount);\\n _burn(account, amount);\\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\":\"0xea2c6f9d434127bf36b1e3e5ebaaf6d28a64dbaeea560508e570014e905a5ad2\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable-4.7.3/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\"},\"contracts/AmplificationUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./SwapUtilsV2.sol\\\";\\n\\n/**\\n * @title AmplificationUtils library\\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct.\\n * This library assumes the struct is fully validated.\\n */\\nlibrary AmplificationUtilsV2 {\\n event RampA(\\n uint256 oldA,\\n uint256 newA,\\n uint256 initialTime,\\n uint256 futureTime\\n );\\n event StopRampA(uint256 currentA, uint256 time);\\n\\n // Constant values used in ramping A calculations\\n uint256 public constant A_PRECISION = 100;\\n uint256 public constant MAX_A = 10**6;\\n uint256 private constant MAX_A_CHANGE = 2;\\n uint256 private constant MIN_RAMP_TIME = 14 days;\\n\\n /**\\n * @notice Return A, the amplification coefficient * n * (n - 1)\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter\\n */\\n function getA(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return (_getAPrecise(self) / A_PRECISION);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function getAPrecise(SwapUtilsV2.Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n return _getAPrecise(self);\\n }\\n\\n /**\\n * @notice Return A in its raw precision\\n * @dev See the StableSwap paper for details\\n * @param self Swap struct to read from\\n * @return A parameter in its raw precision form\\n */\\n function _getAPrecise(SwapUtilsV2.Swap storage self)\\n internal\\n view\\n returns (uint256)\\n {\\n uint256 t1 = self.futureATime; // time when ramp is finished\\n uint256 a1 = self.futureA; // final A value when ramp is finished\\n\\n if (block.timestamp < t1) {\\n uint256 t0 = self.initialATime; // time when ramp is started\\n uint256 a0 = self.initialA; // initial A value when ramp is started\\n if (a1 > a0) {\\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\\n return a0 + (((a1 - a0) * (block.timestamp - t0)) / (t1 - t0));\\n } else {\\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\\n return a0 - (((a0 - a1) * (block.timestamp - t0)) / (t1 - t0));\\n }\\n } else {\\n return a1;\\n }\\n }\\n\\n /**\\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\\n * Checks if the change is too rapid, and commits the new A value only when it falls under\\n * the limit range.\\n * @param self Swap struct to update\\n * @param futureA_ the new A to ramp towards\\n * @param futureTime_ timestamp when the new A should be reached\\n */\\n function rampA(\\n SwapUtilsV2.Swap storage self,\\n uint256 futureA_,\\n uint256 futureTime_\\n ) external {\\n require(\\n block.timestamp >= (self.initialATime + (1 days)),\\n \\\"Wait 1 day before starting ramp\\\"\\n );\\n require(\\n futureTime_ >= (block.timestamp + MIN_RAMP_TIME),\\n \\\"Insufficient ramp time\\\"\\n );\\n require(\\n futureA_ > 0 && futureA_ < MAX_A,\\n \\\"futureA_ must be > 0 and < MAX_A\\\"\\n );\\n\\n uint256 initialAPrecise = _getAPrecise(self);\\n uint256 futureAPrecise = futureA_ * A_PRECISION;\\n\\n if (futureAPrecise < initialAPrecise) {\\n require(\\n (futureAPrecise * MAX_A_CHANGE) >= initialAPrecise,\\n \\\"futureA_ is too small\\\"\\n );\\n } else {\\n require(\\n futureAPrecise <= (initialAPrecise * MAX_A_CHANGE),\\n \\\"futureA_ is too large\\\"\\n );\\n }\\n\\n self.initialA = initialAPrecise;\\n self.futureA = futureAPrecise;\\n self.initialATime = block.timestamp;\\n self.futureATime = futureTime_;\\n\\n emit RampA(\\n initialAPrecise,\\n futureAPrecise,\\n block.timestamp,\\n futureTime_\\n );\\n }\\n\\n /**\\n * @notice Stops ramping A immediately. Once this function is called, rampA()\\n * cannot be called for another 24 hours\\n * @param self Swap struct to update\\n */\\n function stopRampA(SwapUtilsV2.Swap storage self) external {\\n require(self.futureATime > block.timestamp, \\\"Ramp is already stopped\\\");\\n\\n uint256 currentA = _getAPrecise(self);\\n self.initialA = currentA;\\n self.futureA = currentA;\\n self.initialATime = block.timestamp;\\n self.futureATime = block.timestamp;\\n\\n emit StopRampA(currentA, block.timestamp);\\n }\\n}\\n\",\"keccak256\":\"0xb52146d1964ede58f1cb59bff4fa507d30eeae9b11c213941bcbda047fe9e4fb\",\"license\":\"MIT\"},\"contracts/LPTokenV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\\\";\\nimport \\\"./interfaces/ISwapV2.sol\\\";\\n\\n/**\\n * @title Liquidity Provider Token\\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\\n * It is used to represent user's shares when providing liquidity to swap contracts.\\n * @dev Only Swap contracts should initialize and own LPToken contracts.\\n */\\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\\n /**\\n * @notice Initializes this LPToken contract with the given name and symbol\\n * @dev The caller of this function will become the owner. A Swap contract should call this\\n * in its initializer function.\\n * @param name name of this token\\n * @param symbol symbol of this token\\n */\\n function initialize(string memory name, string memory symbol)\\n external\\n initializer\\n returns (bool)\\n {\\n __Context_init_unchained();\\n __ERC20_init_unchained(name, symbol);\\n __Ownable_init_unchained();\\n return true;\\n }\\n\\n /**\\n * @notice Mints the given amount of LPToken to the recipient.\\n * @dev only owner can call this mint function\\n * @param recipient address of account to receive the tokens\\n * @param amount amount of tokens to mint\\n */\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(amount != 0, \\\"LPToken: cannot mint 0\\\");\\n _mint(recipient, amount);\\n }\\n\\n /**\\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\\n * This assumes the owner is set to a Swap contract's address.\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual override(ERC20Upgradeable) {\\n super._beforeTokenTransfer(from, to, amount);\\n require(to != address(this), \\\"LPToken: cannot send to itself\\\");\\n }\\n}\\n\",\"keccak256\":\"0x131705fde9652556cbc06ca58ff86a3f65ce02365e210b9820a8a93195ac35ec\",\"license\":\"MIT\"},\"contracts/MathUtilsV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title MathUtils library\\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\\n * differences between two uint256.\\n */\\nlibrary MathUtilsV1 {\\n /**\\n * @notice Compares a and b and returns true if the difference between a and b\\n * is less than 1 or equal to each other.\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return True if the difference between a and b is less than 1 or equal,\\n * otherwise return false\\n */\\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\\n return (difference(a, b) <= 1);\\n }\\n\\n /**\\n * @notice Calculates absolute difference between a and b\\n * @param a uint256 to compare with\\n * @param b uint256 to compare with\\n * @return Difference between a and b\\n */\\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a > b) {\\n return a - b;\\n }\\n return b - a;\\n }\\n}\\n\",\"keccak256\":\"0x39534ffe365ac4796eebdd5d505ed58c425bc65861ccf118eb0f6cd26c654f0b\",\"license\":\"MIT\"},\"contracts/SwapUtilsV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"./AmplificationUtilsV2.sol\\\";\\nimport \\\"./LPTokenV2.sol\\\";\\nimport \\\"./MathUtilsV1.sol\\\";\\n\\n/**\\n * @title SwapUtils library\\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\\n * Admin functions should be protected within contracts using this library.\\n */\\nlibrary SwapUtilsV2 {\\n using SafeERC20 for IERC20;\\n using MathUtilsV1 for uint256;\\n\\n /*** EVENTS ***/\\n\\n event TokenSwap(\\n address indexed buyer,\\n uint256 tokensSold,\\n uint256 tokensBought,\\n uint128 soldId,\\n uint128 boughtId\\n );\\n event AddLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidity(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256 lpTokenSupply\\n );\\n event RemoveLiquidityOne(\\n address indexed provider,\\n uint256 lpTokenAmount,\\n uint256 lpTokenSupply,\\n uint256 boughtId,\\n uint256 tokensBought\\n );\\n event RemoveLiquidityImbalance(\\n address indexed provider,\\n uint256[] tokenAmounts,\\n uint256[] fees,\\n uint256 invariant,\\n uint256 lpTokenSupply\\n );\\n event NewAdminFee(uint256 newAdminFee);\\n event NewSwapFee(uint256 newSwapFee);\\n\\n struct Swap {\\n // variables around the ramp management of A,\\n // the amplification coefficient * n * (n - 1)\\n // see https://www.curve.fi/stableswap-paper.pdf for details\\n uint256 initialA;\\n uint256 futureA;\\n uint256 initialATime;\\n uint256 futureATime;\\n // fee calculation\\n uint256 swapFee;\\n uint256 adminFee;\\n LPTokenV2 lpToken;\\n // contract references for all tokens being pooled\\n IERC20[] pooledTokens;\\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\\n uint256[] tokenPrecisionMultipliers;\\n // the pool balance of each token, in the token's precision\\n // the contract's actual token balance might differ\\n uint256[] balances;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\\n struct CalculateWithdrawOneTokenDYInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 newY;\\n uint256 feePerToken;\\n uint256 preciseA;\\n }\\n\\n // Struct storing variables used in calculations in the\\n // {add,remove}Liquidity functions to avoid stack too deep errors\\n struct ManageLiquidityInfo {\\n uint256 d0;\\n uint256 d1;\\n uint256 d2;\\n uint256 preciseA;\\n LPTokenV2 lpToken;\\n uint256 totalSupply;\\n uint256[] balances;\\n uint256[] multipliers;\\n }\\n\\n // the precision all pools tokens will be converted to\\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\\n\\n // the denominator used to calculate admin and LP fees. For example, an\\n // LP fee might be something like tradeAmount * (fee) / (FEE_DENOMINATOR)\\n uint256 private constant FEE_DENOMINATOR = 10**10;\\n\\n // Max swap fee is 1% or 100bps of each swap\\n uint256 public constant MAX_SWAP_FEE = 10**8;\\n\\n // Max adminFee is 100% of the swapFee\\n // adminFee does not add additional fee on top of swapFee\\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\\n // users but only on the earnings of LPs\\n uint256 public constant MAX_ADMIN_FEE = 10**10;\\n\\n // Constant value used as max loop limit\\n uint256 private constant MAX_LOOP_LIMIT = 256;\\n\\n /*** VIEW & PURE FUNCTIONS ***/\\n\\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\\n return AmplificationUtilsV2._getAPrecise(self);\\n }\\n\\n /**\\n * @notice Calculate the dy, the amount of selected token that user receives and\\n * the fee of withdrawing in one token\\n * @param tokenAmount the amount to withdraw in the pool's precision\\n * @param tokenIndex which token will be withdrawn\\n * @param self Swap struct to read from\\n * @return the amount of token user will receive\\n */\\n function calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256) {\\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n self.lpToken.totalSupply()\\n );\\n return availableTokenAmount;\\n }\\n\\n function _calculateWithdrawOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 totalSupply\\n ) internal view returns (uint256, uint256) {\\n uint256 dy;\\n uint256 newY;\\n uint256 currentY;\\n\\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\\n self,\\n tokenIndex,\\n tokenAmount,\\n totalSupply\\n );\\n\\n // dy_0 (without fees)\\n // dy, dy_0 - dy\\n\\n uint256 dySwapFee = ((currentY - newY) /\\n self.tokenPrecisionMultipliers[tokenIndex]) - dy;\\n\\n return (dy, dySwapFee);\\n }\\n\\n /**\\n * @notice Calculate the dy of withdrawing in one token\\n * @param self Swap struct to read from\\n * @param tokenIndex which token will be withdrawn\\n * @param tokenAmount the amount to withdraw in the pools precision\\n * @return the d and the new y after withdrawing one token\\n */\\n function calculateWithdrawOneTokenDY(\\n Swap storage self,\\n uint8 tokenIndex,\\n uint256 tokenAmount,\\n uint256 totalSupply\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n // Get the current D, then solve the stableswap invariant\\n // y_i for D - tokenAmount\\n uint256[] memory xp = _xp(self);\\n\\n require(tokenIndex < xp.length, \\\"Token index out of range\\\");\\n\\n CalculateWithdrawOneTokenDYInfo\\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\\n v.preciseA = _getAPrecise(self);\\n v.d0 = getD(xp, v.preciseA);\\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\\n\\n require(tokenAmount <= xp[tokenIndex], \\\"Withdraw exceeds available\\\");\\n\\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\\n\\n uint256[] memory xpReduced = new uint256[](xp.length);\\n\\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\\n for (uint256 i = 0; i < xp.length; i++) {\\n uint256 xpi = xp[i];\\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\\n xpReduced[i] =\\n xpi -\\n (((\\n (i == tokenIndex)\\n ? ((xpi * v.d1) / v.d0) - v.newY\\n : xpi - ((xpi * v.d1) / v.d0)\\n ) * v.feePerToken) / FEE_DENOMINATOR);\\n }\\n\\n uint256 dy = xpReduced[tokenIndex] -\\n (getYD(v.preciseA, tokenIndex, xpReduced, v.d1));\\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\\n\\n return (dy, v.newY, xp[tokenIndex]);\\n }\\n\\n /**\\n * @notice Calculate the price of a token in the pool with given\\n * precision-adjusted balances and a particular D.\\n *\\n * @dev This is accomplished via solving the invariant iteratively.\\n * See the StableSwap paper and Curve.fi implementation for further details.\\n *\\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\\n * x_1**2 + b*x_1 = c\\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\\n *\\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\\n * @param tokenIndex Index of token we are calculating for.\\n * @param xp a precision-adjusted set of pool balances. Array should be\\n * the same cardinality as the pool.\\n * @param d the stableswap invariant\\n * @return the price of the token, in the same precision as in xp\\n */\\n function getYD(\\n uint256 a,\\n uint8 tokenIndex,\\n uint256[] memory xp,\\n uint256 d\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(tokenIndex < numTokens, \\\"Token not found\\\");\\n\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = a * (numTokens);\\n\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i != tokenIndex) {\\n s = s + xp[i];\\n c = (c * d) / (xp[i] * (numTokens));\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = ((y * y) + c) / ((y * 2) + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\\n * as the pool.\\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\\n * See the StableSwap paper for details\\n * @return the invariant, at the precision of the pool\\n */\\n function getD(uint256[] memory xp, uint256 a)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 numTokens = xp.length;\\n uint256 s;\\n for (uint256 i = 0; i < numTokens; i++) {\\n s = s + xp[i];\\n }\\n if (s == 0) {\\n return 0;\\n }\\n\\n uint256 prevD;\\n uint256 d = s;\\n uint256 nA = a * numTokens;\\n\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n uint256 dP = d;\\n for (uint256 j = 0; j < numTokens; j++) {\\n dP = (dP * d) / (xp[j] * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // dP = dP * D * D * D * ... overflow!\\n }\\n prevD = d;\\n d =\\n ((((nA * s) / AmplificationUtilsV2.A_PRECISION) +\\n (dP * numTokens)) * d) /\\n ((((nA - AmplificationUtilsV2.A_PRECISION) * d) /\\n AmplificationUtilsV2.A_PRECISION) + ((numTokens + 1) * dP));\\n if (d.within1(prevD)) {\\n return d;\\n }\\n }\\n\\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\\n // function which does not rely on D.\\n revert(\\\"D does not converge\\\");\\n }\\n\\n /**\\n * @notice Given a set of balances and precision multipliers, return the\\n * precision-adjusted balances.\\n *\\n * @param balances an array of token balances, in their native precisions.\\n * These should generally correspond with pooled tokens.\\n *\\n * @param precisionMultipliers an array of multipliers, corresponding to\\n * the amounts in the balances array. When multiplied together they\\n * should yield amounts at the pool's precision.\\n *\\n * @return an array of amounts \\\"scaled\\\" to the pool's precision\\n */\\n function _xp(\\n uint256[] memory balances,\\n uint256[] memory precisionMultipliers\\n ) internal pure returns (uint256[] memory) {\\n uint256 numTokens = balances.length;\\n require(\\n numTokens == precisionMultipliers.length,\\n \\\"Balances must match multipliers\\\"\\n );\\n uint256[] memory xp = new uint256[](numTokens);\\n for (uint256 i = 0; i < numTokens; i++) {\\n xp[i] = balances[i] * precisionMultipliers[i];\\n }\\n return xp;\\n }\\n\\n /**\\n * @notice Return the precision-adjusted balances of all tokens in the pool\\n * @param self Swap struct to read from\\n * @return the pool balances \\\"scaled\\\" to the pool's precision, allowing\\n * them to be more easily compared.\\n */\\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\\n return _xp(self.balances, self.tokenPrecisionMultipliers);\\n }\\n\\n /**\\n * @notice Get the virtual price, to help calculate profit\\n * @param self Swap struct to read from\\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\\n */\\n function getVirtualPrice(Swap storage self)\\n external\\n view\\n returns (uint256)\\n {\\n uint256 d = getD(_xp(self), _getAPrecise(self));\\n LPTokenV2 lpToken = self.lpToken;\\n uint256 supply = lpToken.totalSupply();\\n if (supply > 0) {\\n return (d * (10**uint256(POOL_PRECISION_DECIMALS))) / supply;\\n }\\n return 0;\\n }\\n\\n /**\\n * @notice Calculate the new balances of the tokens given the indexes of the token\\n * that is swapped from (FROM) and the token that is swapped to (TO).\\n * This function is used as a helper function to calculate how much TO token\\n * the user should receive on swap.\\n *\\n * @param preciseA precise form of amplification coefficient\\n * @param tokenIndexFrom index of FROM token\\n * @param tokenIndexTo index of TO token\\n * @param x the new total amount of FROM token\\n * @param xp balances of the tokens in the pool\\n * @return the amount of TO token that should remain in the pool\\n */\\n function getY(\\n uint256 preciseA,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 x,\\n uint256[] memory xp\\n ) internal pure returns (uint256) {\\n uint256 numTokens = xp.length;\\n require(\\n tokenIndexFrom != tokenIndexTo,\\n \\\"Can't compare token to itself\\\"\\n );\\n require(\\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\\n \\\"Tokens must be in pool\\\"\\n );\\n\\n uint256 d = getD(xp, preciseA);\\n uint256 c = d;\\n uint256 s;\\n uint256 nA = numTokens * preciseA;\\n\\n uint256 _x;\\n for (uint256 i = 0; i < numTokens; i++) {\\n if (i == tokenIndexFrom) {\\n _x = x;\\n } else if (i != tokenIndexTo) {\\n _x = xp[i];\\n } else {\\n continue;\\n }\\n s = s + _x;\\n c = (c * d) / (_x * numTokens);\\n // If we were to protect the division loss we would have to keep the denominator separate\\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\\n // c = c * D * D * D * ... overflow!\\n }\\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\\n uint256 yPrev;\\n uint256 y = d;\\n\\n // iterative approximation\\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\\n yPrev = y;\\n y = (y * y + c) / (y * 2 + b - d);\\n if (y.within1(yPrev)) {\\n return y;\\n }\\n }\\n revert(\\\"Approximation did not converge\\\");\\n }\\n\\n /**\\n * @notice Externally calculates a swap between two tokens.\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n */\\n function calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256 dy) {\\n (dy, ) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n self.balances\\n );\\n }\\n\\n /**\\n * @notice Internally calculates a swap between two tokens.\\n *\\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\\n * using the token contracts.\\n *\\n * @param self Swap struct to read from\\n * @param tokenIndexFrom the token to sell\\n * @param tokenIndexTo the token to buy\\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @return dy the number of tokens the user will get\\n * @return dyFee the associated fee\\n */\\n function _calculateSwap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256[] memory balances\\n ) internal view returns (uint256 dy, uint256 dyFee) {\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n uint256[] memory xp = _xp(balances, multipliers);\\n require(\\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\\n \\\"Token index out of range\\\"\\n );\\n uint256 x = dx * multipliers[tokenIndexFrom] + xp[tokenIndexFrom];\\n uint256 y = getY(\\n _getAPrecise(self),\\n tokenIndexFrom,\\n tokenIndexTo,\\n x,\\n xp\\n );\\n dy = xp[tokenIndexTo] - y - 1;\\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\\n dy = (dy - dyFee) / multipliers[tokenIndexTo];\\n }\\n\\n /**\\n * @notice A simple method to calculate amount of each underlying\\n * tokens that is returned upon burning given amount of\\n * LP tokens\\n *\\n * @param amount the amount of LP tokens that would to be burned on\\n * withdrawal\\n * @return array of amounts of tokens user will receive\\n */\\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\\n external\\n view\\n returns (uint256[] memory)\\n {\\n return\\n _calculateRemoveLiquidity(\\n self.balances,\\n amount,\\n self.lpToken.totalSupply()\\n );\\n }\\n\\n function _calculateRemoveLiquidity(\\n uint256[] memory balances,\\n uint256 amount,\\n uint256 totalSupply\\n ) internal pure returns (uint256[] memory) {\\n require(amount <= totalSupply, \\\"Cannot exceed total supply\\\");\\n\\n uint256[] memory amounts = new uint256[](balances.length);\\n\\n for (uint256 i = 0; i < balances.length; i++) {\\n amounts[i] = (balances[i] * amount) / totalSupply;\\n }\\n return amounts;\\n }\\n\\n /**\\n * @notice A simple method to calculate prices from deposits or\\n * withdrawals, excluding fees but including slippage. This is\\n * helpful as an input into the various \\\"min\\\" parameters on calls\\n * to fight front-running\\n *\\n * @dev This shouldn't be used outside frontends for user estimates.\\n *\\n * @param self Swap struct to read from\\n * @param amounts an array of token amounts to deposit or withdrawal,\\n * corresponding to pooledTokens. The amount should be in each\\n * pooled token's native precision. If a token charges a fee on transfers,\\n * use the amount that gets transferred after the fee.\\n * @param deposit whether this is a deposit or a withdrawal\\n * @return if deposit was true, total amount of lp token that will be minted and if\\n * deposit was false, total amount of lp token that will be burned\\n */\\n function calculateTokenAmount(\\n Swap storage self,\\n uint256[] calldata amounts,\\n bool deposit\\n ) external view returns (uint256) {\\n uint256 a = _getAPrecise(self);\\n uint256[] memory balances = self.balances;\\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\\n\\n uint256 d0 = getD(_xp(balances, multipliers), a);\\n for (uint256 i = 0; i < balances.length; i++) {\\n if (deposit) {\\n balances[i] = balances[i] + amounts[i];\\n } else {\\n if (amounts[i] > balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances[i] = balances[i] - amounts[i];\\n }\\n }\\n }\\n }\\n uint256 d1 = getD(_xp(balances, multipliers), a);\\n uint256 totalSupply = self.lpToken.totalSupply();\\n\\n if (deposit) {\\n return (((d1 - d0) * totalSupply) / d0);\\n } else {\\n return (((d0 - d1) * totalSupply) / d0);\\n }\\n }\\n\\n /**\\n * @notice return accumulated amount of admin fees of the token with given index\\n * @param self Swap struct to read from\\n * @param index Index of the pooled token\\n * @return admin balance in the token's precision\\n */\\n function getAdminBalance(Swap storage self, uint256 index)\\n external\\n view\\n returns (uint256)\\n {\\n require(index < self.pooledTokens.length, \\\"Token index out of range\\\");\\n return\\n self.pooledTokens[index].balanceOf(address(this)) -\\n self.balances[index];\\n }\\n\\n /**\\n * @notice internal helper function to calculate fee per token multiplier used in\\n * swap fee calculations\\n * @param swapFee swap fee for the tokens\\n * @param numTokens number of tokens pooled\\n */\\n function _feePerToken(uint256 swapFee, uint256 numTokens)\\n internal\\n pure\\n returns (uint256)\\n {\\n return ((swapFee * numTokens) / ((numTokens - 1) * 4));\\n }\\n\\n /*** STATE MODIFYING FUNCTIONS ***/\\n\\n /**\\n * @notice swap two tokens in the pool\\n * @param self Swap struct to read from and write to\\n * @param tokenIndexFrom the token the user wants to sell\\n * @param tokenIndexTo the token the user wants to buy\\n * @param dx the amount of tokens the user wants to sell\\n * @param minDy the min amount the user would like to receive, or revert.\\n * @return amount of token user received on swap\\n */\\n function swap(\\n Swap storage self,\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy\\n ) external returns (uint256) {\\n {\\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\\n require(\\n dx <= tokenFrom.balanceOf(msg.sender),\\n \\\"Cannot swap more than you own\\\"\\n );\\n // Transfer tokens first to see if a fee was charged on transfer\\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\\n\\n // Use the actual transferred amount for AMM math\\n dx = tokenFrom.balanceOf(address(this)) - beforeBalance;\\n }\\n\\n uint256 dy;\\n uint256 dyFee;\\n uint256[] memory balances = self.balances;\\n (dy, dyFee) = _calculateSwap(\\n self,\\n tokenIndexFrom,\\n tokenIndexTo,\\n dx,\\n balances\\n );\\n require(dy >= minDy, \\\"Swap didn't result in min tokens\\\");\\n\\n uint256 dyAdminFee = (((dyFee * self.adminFee) / FEE_DENOMINATOR) /\\n self.tokenPrecisionMultipliers[tokenIndexTo]);\\n\\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom] + dx;\\n self.balances[tokenIndexTo] = balances[tokenIndexTo] - dy - dyAdminFee;\\n\\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\\n\\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Add liquidity to the pool\\n * @param self Swap struct to read from and write to\\n * @param amounts the amounts of each token to add, in their native precision\\n * @param minToMint the minimum LP tokens adding this amount of liquidity\\n * should mint, otherwise revert. Handy for front-running mitigation\\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\\n * @return amount of LP token user received\\n */\\n function addLiquidity(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 minToMint\\n ) external returns (uint256) {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts must match pooled tokens\\\"\\n );\\n\\n // current state\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n if (v.totalSupply != 0) {\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n }\\n\\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n require(\\n v.totalSupply != 0 || amounts[i] > 0,\\n \\\"Must supply all tokens in pool\\\"\\n );\\n\\n // Transfer tokens first to see if a fee was charged on transfer\\n if (amounts[i] != 0) {\\n uint256 beforeBalance = pooledTokens[i].balanceOf(\\n address(this)\\n );\\n pooledTokens[i].safeTransferFrom(\\n msg.sender,\\n address(this),\\n amounts[i]\\n );\\n\\n // Update the amounts[] with actual transfer amount\\n amounts[i] =\\n pooledTokens[i].balanceOf(address(this)) -\\n beforeBalance;\\n }\\n\\n newBalances[i] = v.balances[i] + amounts[i];\\n }\\n // invariant after change\\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n require(v.d1 > v.d0, \\\"D should increase\\\");\\n // updated to reflect fees and calculate the user's LP tokens\\n v.d2 = v.d1;\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n\\n if (v.totalSupply != 0) {\\n uint256 feePerToken = _feePerToken(\\n self.swapFee,\\n pooledTokens.length\\n );\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n fees[i] =\\n (feePerToken * idealBalance.difference(newBalances[i])) /\\n FEE_DENOMINATOR;\\n self.balances[i] =\\n newBalances[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n newBalances[i] = newBalances[i] - fees[i];\\n }\\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\\n } else {\\n // the initial depositor doesn't pay fees\\n self.balances = newBalances;\\n }\\n\\n uint256 toMint;\\n if (v.totalSupply == 0) {\\n toMint = v.d1;\\n } else {\\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\\n }\\n\\n require(toMint >= minToMint, \\\"Couldn't mint min requested\\\");\\n\\n // mint the user's LP tokens\\n v.lpToken.mint(msg.sender, toMint);\\n\\n emit AddLiquidity(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply + toMint\\n );\\n\\n return toMint;\\n }\\n\\n /**\\n * @notice Burn LP tokens to remove liquidity from the pool.\\n * @dev Liquidity can always be removed, even when the pool is paused.\\n * @param self Swap struct to read from and write to\\n * @param amount the amount of LP tokens to burn\\n * @param minAmounts the minimum amounts of each token in the pool\\n * acceptable for this burn. Useful as a front-running mitigation\\n * @return amounts of tokens the user received\\n */\\n function removeLiquidity(\\n Swap storage self,\\n uint256 amount,\\n uint256[] calldata minAmounts\\n ) external returns (uint256[] memory) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n require(amount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(\\n minAmounts.length == pooledTokens.length,\\n \\\"minAmounts must match poolTokens\\\"\\n );\\n\\n uint256[] memory balances = self.balances;\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n uint256[] memory amounts = _calculateRemoveLiquidity(\\n balances,\\n amount,\\n totalSupply\\n );\\n\\n for (uint256 i = 0; i < amounts.length; i++) {\\n require(amounts[i] >= minAmounts[i], \\\"amounts[i] < minAmounts[i]\\\");\\n self.balances[i] = balances[i] - amounts[i];\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n lpToken.burnFrom(msg.sender, amount);\\n\\n emit RemoveLiquidity(msg.sender, amounts, totalSupply - amount);\\n\\n return amounts;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool all in one token.\\n * @param self Swap struct to read from and write to\\n * @param tokenAmount the amount of the lp tokens to burn\\n * @param tokenIndex the index of the token you want to receive\\n * @param minAmount the minimum amount to withdraw, otherwise revert\\n * @return amount chosen token that user received\\n */\\n function removeLiquidityOneToken(\\n Swap storage self,\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount\\n ) external returns (uint256) {\\n LPTokenV2 lpToken = self.lpToken;\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \\\">LP.balanceOf\\\");\\n require(tokenIndex < pooledTokens.length, \\\"Token not found\\\");\\n\\n uint256 totalSupply = lpToken.totalSupply();\\n\\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\\n self,\\n tokenAmount,\\n tokenIndex,\\n totalSupply\\n );\\n\\n require(dy >= minAmount, \\\"dy < minAmount\\\");\\n\\n self.balances[tokenIndex] =\\n self.balances[tokenIndex] -\\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\\n lpToken.burnFrom(msg.sender, tokenAmount);\\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\\n\\n emit RemoveLiquidityOne(\\n msg.sender,\\n tokenAmount,\\n totalSupply,\\n tokenIndex,\\n dy\\n );\\n\\n return dy;\\n }\\n\\n /**\\n * @notice Remove liquidity from the pool, weighted differently than the\\n * pool's current balances.\\n *\\n * @param self Swap struct to read from and write to\\n * @param amounts how much of each token to withdraw\\n * @param maxBurnAmount the max LP token provider is willing to pay to\\n * remove liquidity. Useful as a front-running mitigation.\\n * @return actual amount of LP tokens burned in the withdrawal\\n */\\n function removeLiquidityImbalance(\\n Swap storage self,\\n uint256[] memory amounts,\\n uint256 maxBurnAmount\\n ) public returns (uint256) {\\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\\n 0,\\n 0,\\n 0,\\n _getAPrecise(self),\\n self.lpToken,\\n 0,\\n self.balances,\\n self.tokenPrecisionMultipliers\\n );\\n v.totalSupply = v.lpToken.totalSupply();\\n\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n\\n require(\\n amounts.length == pooledTokens.length,\\n \\\"Amounts should match pool tokens\\\"\\n );\\n\\n require(\\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\\n maxBurnAmount != 0,\\n \\\">LP.balanceOf\\\"\\n );\\n\\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\\n uint256[] memory fees = new uint256[](pooledTokens.length);\\n {\\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n if (amounts[i] > v.balances[i]) {\\n revert(\\\"Cannot withdraw more than available\\\");\\n } else {\\n unchecked {\\n balances1[i] = v.balances[i] - amounts[i];\\n }\\n }\\n }\\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\\n uint256 difference = idealBalance.difference(balances1[i]);\\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\\n self.balances[i] =\\n balances1[i] -\\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\\n balances1[i] = balances1[i] - fees[i];\\n }\\n\\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\\n }\\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\\n require(tokenAmount != 0, \\\"Burnt amount cannot be zero\\\");\\n tokenAmount = tokenAmount + 1;\\n\\n require(tokenAmount <= maxBurnAmount, \\\"tokenAmount > maxBurnAmount\\\");\\n\\n v.lpToken.burnFrom(msg.sender, tokenAmount);\\n\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\\n }\\n\\n emit RemoveLiquidityImbalance(\\n msg.sender,\\n amounts,\\n fees,\\n v.d1,\\n v.totalSupply - tokenAmount\\n );\\n\\n return tokenAmount;\\n }\\n\\n /**\\n * @notice withdraw all admin fees to a given address\\n * @param self Swap struct to withdraw fees from\\n * @param to Address to send the fees to\\n */\\n function withdrawAdminFees(Swap storage self, address to) external {\\n IERC20[] memory pooledTokens = self.pooledTokens;\\n for (uint256 i = 0; i < pooledTokens.length; i++) {\\n IERC20 token = pooledTokens[i];\\n uint256 balance = token.balanceOf(address(this)) - self.balances[i];\\n if (balance != 0) {\\n token.safeTransfer(to, balance);\\n }\\n }\\n }\\n\\n /**\\n * @notice Sets the admin fee\\n * @dev adminFee cannot be higher than 100% of the swap fee\\n * @param self Swap struct to update\\n * @param newAdminFee new admin fee to be applied on future transactions\\n */\\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\\n require(newAdminFee <= MAX_ADMIN_FEE, \\\"Fee is too high\\\");\\n self.adminFee = newAdminFee;\\n\\n emit NewAdminFee(newAdminFee);\\n }\\n\\n /**\\n * @notice update the swap fee\\n * @dev fee cannot be higher than 1% of each swap\\n * @param self Swap struct to update\\n * @param newSwapFee new swap fee to be applied on future transactions\\n */\\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\\n require(newSwapFee <= MAX_SWAP_FEE, \\\"Fee is too high\\\");\\n self.swapFee = newSwapFee;\\n\\n emit NewSwapFee(newSwapFee);\\n }\\n}\\n\",\"keccak256\":\"0xb8d3f47b58b85bddeeb59cc13049f3f7fee2b29ee373fe5427d1f7c8814a1b8b\",\"license\":\"MIT\"},\"contracts/interfaces/IAllowlistV1.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\ninterface IAllowlistV1 {\\n function getPoolAccountLimit(address poolAddress)\\n external\\n view\\n returns (uint256);\\n\\n function getPoolCap(address poolAddress) external view returns (uint256);\\n\\n function verifyAddress(address account, bytes32[] calldata merkleProof)\\n external\\n returns (bool);\\n}\\n\",\"keccak256\":\"0xe789ec166e4b0827a94894104dc0a9ac99b2f6412a29841c851a5f794db9de57\",\"license\":\"MIT\"},\"contracts/interfaces/ISwapV2.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\\\";\\nimport \\\"./IAllowlistV1.sol\\\";\\n\\ninterface ISwapV2 {\\n // pool data view functions\\n function getA() external view returns (uint256);\\n\\n function getAPrecise() external view returns (uint256);\\n\\n function getAllowlist() external view returns (IAllowlistV1);\\n\\n function getToken(uint8 index) external view returns (IERC20);\\n\\n function getTokenIndex(address tokenAddress) external view returns (uint8);\\n\\n function getTokenBalance(uint8 index) external view returns (uint256);\\n\\n function getVirtualPrice() external view returns (uint256);\\n\\n function owner() external view returns (address);\\n\\n function isGuarded() external view returns (bool);\\n\\n function paused() external view returns (bool);\\n\\n function swapStorage()\\n external\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n uint256,\\n address\\n );\\n\\n // min return calculation functions\\n function calculateSwap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx\\n ) external view returns (uint256);\\n\\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\\n external\\n view\\n returns (uint256);\\n\\n function calculateRemoveLiquidity(uint256 amount)\\n external\\n view\\n returns (uint256[] memory);\\n\\n function calculateRemoveLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex\\n ) external view returns (uint256 availableTokenAmount);\\n\\n // state modifying functions\\n function initialize(\\n IERC20[] memory pooledTokens,\\n uint8[] memory decimals,\\n string memory lpTokenName,\\n string memory lpTokenSymbol,\\n uint256 a,\\n uint256 fee,\\n uint256 adminFee,\\n address lpTokenTargetAddress\\n ) external;\\n\\n function swap(\\n uint8 tokenIndexFrom,\\n uint8 tokenIndexTo,\\n uint256 dx,\\n uint256 minDy,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function addLiquidity(\\n uint256[] calldata amounts,\\n uint256 minToMint,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidity(\\n uint256 amount,\\n uint256[] calldata minAmounts,\\n uint256 deadline\\n ) external returns (uint256[] memory);\\n\\n function removeLiquidityOneToken(\\n uint256 tokenAmount,\\n uint8 tokenIndex,\\n uint256 minAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n\\n function removeLiquidityImbalance(\\n uint256[] calldata amounts,\\n uint256 maxBurnAmount,\\n uint256 deadline\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0xfa36e88ed32dff2507fe11112ee47d4bf05784a28286ffff4f55b1b9f19f16f8\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x6146bd61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106101255760003560e01c80638424905f116100bc578063acf914781161008b578063f3de036211610070578063f3de0362146102a3578063fa76ee2a146102af578063fe7cb1c0146102cf57600080fd5b8063acf9147814610270578063cbc7f8dd1461029057600080fd5b80638424905f1461021257806398a20a3e14610232578063a125d92414610245578063ab3d85441461026557600080fd5b806339e43af2116100f857806339e43af2146101ac5780634540fb7f146101bf5780636972fae8146101df578063711cd330146101f257600080fd5b80630296ab501461012a578063041894b01461014957806305f7ec21146101775780631a535da514610199575b600080fd5b610132601281565b60405160ff90911681526020015b60405180910390f35b81801561015557600080fd5b50610169610164366004613f2c565b6102ef565b604051908152602001610140565b81801561018357600080fd5b5061019761019236600461401c565b610ca3565b005b6101696101a7366004614054565b610d36565b6101696101ba366004614089565b610dc7565b8180156101cb57600080fd5b506101696101da366004613f2c565b610e28565b6101696101ed36600461412a565b6116e1565b8180156101fe57600080fd5b5061016961020d366004614189565b611a0e565b61022561022036600461401c565b611dd4565b60405161014091906141b6565b6101696102403660046141fa565b611eb4565b81801561025157600080fd5b5061019761026036600461401c565b611f90565b6101696305f5e10081565b81801561027c57600080fd5b5061016961028b366004614213565b61201c565b61016961029e36600461401c565b61248b565b6101696402540be40081565b8180156102bb57600080fd5b506102256102ca366004614261565b6125ae565b8180156102db57600080fd5b506101976102ea3660046142b4565b6129f1565b6000808460070180548060200260200160405190810160405280929190818152602001828054801561034a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161032c575b5050505050905080518451146103a75760405162461bcd60e51b815260206004820181905260248201527f416d6f756e7473206d757374206d6174636820706f6f6c656420746f6b656e7360448201526064015b60405180910390fd5b60006040518061010001604052806000815260200160008152602001600081526020016103d388612b61565b81526020018760060160009054906101000a90046001600160a01b03166001600160a01b03168152602001600081526020018760090180548060200260200160405190810160405280929190818152602001828054801561045357602002820191906000526020600020905b81548152602001906001019080831161043f575b50505050508152602001876008018054806020026020016040519081016040528092919081815260200182805480156104ab57602002820191906000526020600020905b815481526020019060010190808311610497575b5050505050815250905080608001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051b91906142f0565b60a08201819052156105495761054661053c8260c001518360e00151612b6c565b8260600151612c8a565b81525b6000825167ffffffffffffffff81111561056557610565613efd565b60405190808252806020026020018201604052801561058e578160200160208202803683370190505b50905060005b83518110156108655760a08301511515806105c8575060008782815181106105be576105be614309565b6020026020010151115b6106145760405162461bcd60e51b815260206004820152601e60248201527f4d75737420737570706c7920616c6c20746f6b656e7320696e20706f6f6c0000604482015260640161039e565b86818151811061062657610626614309565b60200260200101516000146107f457600084828151811061064957610649614309565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d691906142f0565b905061072a33308a85815181106106ef576106ef614309565b602002602001015188868151811061070957610709614309565b60200260200101516001600160a01b0316612e5f909392919063ffffffff16565b8085838151811061073d5761073d614309565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156107a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ca91906142f0565b6107d49190614367565b8883815181106107e6576107e6614309565b602002602001018181525050505b86818151811061080657610806614309565b60200260200101518360c00151828151811061082457610824614309565b6020026020010151610836919061437a565b82828151811061084857610848614309565b60209081029190910101528061085d8161438d565b915050610594565b50610881610877828460e00151612b6c565b8360600151612c8a565b602083018190528251106108d75760405162461bcd60e51b815260206004820152601160248201527f442073686f756c6420696e637265617365000000000000000000000000000000604482015260640161039e565b60208201516040830152825160009067ffffffffffffffff8111156108fe576108fe613efd565b604051908082528060200260200182016040528015610927578160200160208202803683370190505b5090508260a00151600014610b0e57600061094789600401548651612f2e565b905060005b8551811015610ae757600085600001518660c00151838151811061097257610972614309565b6020026020010151876020015161098991906143c5565b61099391906143dc565b90506402540be4006109c78684815181106109b0576109b0614309565b602002602001015183612f5a90919063ffffffff16565b6109d190856143c5565b6109db91906143dc565b8483815181106109ed576109ed614309565b6020026020010181815250506402540be4008b60050154858481518110610a1657610a16614309565b6020026020010151610a2891906143c5565b610a3291906143dc565b858381518110610a4457610a44614309565b6020026020010151610a569190614367565b8b6009018381548110610a6b57610a6b614309565b9060005260206000200181905550838281518110610a8b57610a8b614309565b6020026020010151858381518110610aa557610aa5614309565b6020026020010151610ab79190614367565b858381518110610ac957610ac9614309565b60209081029190910101525080610adf8161438d565b91505061094c565b50610b03610af9848660e00151612b6c565b8560600151612c8a565b604085015250610b25565b8151610b239060098a01906020850190613e9d565b505b60008360a00151600003610b3e57506020830151610b6c565b835160a08501516040860151610b55908390614367565b610b5f91906143c5565b610b6991906143dc565b90505b86811015610bbc5760405162461bcd60e51b815260206004820152601b60248201527f436f756c646e2774206d696e74206d696e207265717565737465640000000000604482015260640161039e565b60808401516040517f40c10f19000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b158015610c2357600080fd5b505af1158015610c37573d6000803e3d6000fd5b50505050336001600160a01b03167f189c623b666b1b45b83d7178f39b8c087cb09774317ca2f53c2d3c3726f222a289848760200151858960a00151610c7d919061437a565b604051610c8d9493929190614452565b60405180910390a29450505050505b9392505050565b6305f5e100811115610cf75760405162461bcd60e51b815260206004820152600f60248201527f46656520697320746f6f20686967680000000000000000000000000000000000604482015260640161039e565b600482018190556040518181527fd88ea5155021c6f8dafa1a741e173f595cdf77ce7c17d43342131d7f06afdfe5906020015b60405180910390a15050565b600080610dbd8585858860060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db891906142f0565b612f7f565b5095945050505050565b6000610dbd8585858589600901805480602002602001604051908101604052809291908181526020018280548015610e1e57602002820191906000526020600020905b815481526020019060010190808311610e0a575b5050505050612ff6565b600080604051806101000160405280600081526020016000815260200160008152602001610e5587612b61565b81526020018660060160009054906101000a90046001600160a01b03166001600160a01b031681526020016000815260200186600901805480602002602001604051908101604052809291908181526020018280548015610ed557602002820191906000526020600020905b815481526020019060010190808311610ec1575b5050505050815260200186600801805480602002602001604051908101604052809291908181526020018280548015610f2d57602002820191906000526020600020905b815481526020019060010190808311610f19575b5050505050815250905080608001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9d91906142f0565b60a08201526007850180546040805160208084028201810190925282815260009390929091830182828015610ffb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fdd575b5050505050905080518551146110535760405162461bcd60e51b815260206004820181905260248201527f416d6f756e74732073686f756c64206d6174636820706f6f6c20746f6b656e73604482015260640161039e565b60808201516040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156110b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110da91906142f0565b84111580156110e857508315155b6111345760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b600061114587600401548351612f2e565b90506000825167ffffffffffffffff81111561116357611163613efd565b60405190808252806020026020018201604052801561118c578160200160208202803683370190505b5090506000835167ffffffffffffffff8111156111ab576111ab613efd565b6040519080825280602002602001820160405280156111d4578160200160208202803683370190505b5090506111f66111ec8660c001518760e00151612b6c565b8660600151612c8a565b855260005b8451811015611319578560c00151818151811061121a5761121a614309565b602002602001015189828151811061123457611234614309565b602002602001015111156112b05760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c650000000000000000000000000000000000000000000000000000000000606482015260840161039e565b8881815181106112c2576112c2614309565b60200260200101518660c0015182815181106112e0576112e0614309565b6020026020010151038282815181106112fb576112fb614309565b602002602001018181525050806113118161438d565b9150506111fb565b5061132b6111ec828760e00151612b6c565b602086015260005b84518110156114be57600086600001518760c00151838151811061135957611359614309565b6020026020010151886020015161137091906143c5565b61137a91906143dc565b905060006113938484815181106109b0576109b0614309565b90506402540be4006113a582886143c5565b6113af91906143dc565b8584815181106113c1576113c1614309565b6020026020010181815250506402540be4008c600501548685815181106113ea576113ea614309565b60200260200101516113fc91906143c5565b61140691906143dc565b84848151811061141857611418614309565b602002602001015161142a9190614367565b8c600901848154811061143f5761143f614309565b906000526020600020018190555084838151811061145f5761145f614309565b602002602001015184848151811061147957611479614309565b602002602001015161148b9190614367565b84848151811061149d5761149d614309565b602002602001018181525050505080806114b69061438d565b915050611333565b506114d06111ec828760e00151612b6c565b60408601819052855160a08701516000935090916114ee9083614367565b6114f891906143c5565b61150291906143dc565b9050806000036115545760405162461bcd60e51b815260206004820152601b60248201527f4275726e7420616d6f756e742063616e6e6f74206265207a65726f0000000000604482015260640161039e565b61155f81600161437a565b9050868111156115b15760405162461bcd60e51b815260206004820152601b60248201527f746f6b656e416d6f756e74203e206d61784275726e416d6f756e740000000000604482015260640161039e565b60808501516040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561161857600080fd5b505af115801561162c573d6000803e3d6000fd5b5050505060005b845181101561169e5761168c338a838151811061165257611652614309565b602002602001015187848151811061166c5761166c614309565b60200260200101516001600160a01b03166131c79092919063ffffffff16565b806116968161438d565b915050611633565b50336001600160a01b03167f3631c28b1f9dd213e0319fb167b554d76b6c283a41143eb400a0d1adb1af175589848860200151858a60a00151610c7d9190614367565b6000806116ed86612b61565b905060008660090180548060200260200160405190810160405280929190818152602001828054801561173f57602002820191906000526020600020905b81548152602001906001019080831161172b575b5050505050905060008760080180548060200260200160405190810160405280929190818152602001828054801561179657602002820191906000526020600020905b815481526020019060010190808311611782575b5050505050905060006117b26117ac8484612b6c565b85612c8a565b905060005b8351811015611932578615611826578888828181106117d8576117d8614309565b905060200201358482815181106117f1576117f1614309565b6020026020010151611803919061437a565b84828151811061181557611815614309565b602002602001018181525050611920565b83818151811061183857611838614309565b602002602001015189898381811061185257611852614309565b9050602002013511156118cd5760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c650000000000000000000000000000000000000000000000000000000000606482015260840161039e565b8888828181106118df576118df614309565b905060200201358482815181106118f8576118f8614309565b60200260200101510384828151811061191357611913614309565b6020026020010181815250505b8061192a8161438d565b9150506117b7565b5060006119486119428585612b6c565b86612c8a565b905060008a60060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c591906142f0565b905087156119fa5782816119d98285614367565b6119e391906143c5565b6119ed91906143dc565b9650505050505050611a06565b82816119d98483614367565b949350505050565b6006840154600785018054604080516020808402820181019092528281526000946001600160a01b03169385939192909190830182828015611a7957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a5b575b50506040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015293945050506001600160a01b038416916370a082319150602401602060405180830381865afa158015611ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0291906142f0565b861115611b515760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b80518560ff1610611ba45760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e640000000000000000000000000000000000604482015260640161039e565b6000826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611be4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0891906142f0565b9050600080611c198a8a8a86612f7f565b9150915086821015611c6d5760405162461bcd60e51b815260206004820152600e60248201527f6479203c206d696e416d6f756e74000000000000000000000000000000000000604482015260640161039e565b6402540be4008a6005015482611c8391906143c5565b611c8d91906143dc565b611c97908361437a565b8a6009018960ff1681548110611caf57611caf614309565b9060005260206000200154611cc49190614367565b8a6009018960ff1681548110611cdc57611cdc614309565b6000918252602090912001556040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b158015611d4957600080fd5b505af1158015611d5d573d6000803e3d6000fd5b50505050611d7b3383868b60ff168151811061166c5761166c614309565b604080518a81526020810185905260ff8a168183015260608101849052905133917f43fb02998f4e03da2e0e6fff53fdbf0c40a9f45f145dc377fc30615d7d7a8a64919081900360800190a25098975050505050505050565b6060611eab83600901805480602002602001604051908101604052809291908181526020018280548015611e2757602002820191906000526020600020905b815481526020019060010190808311611e13575b5050505050838560060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea691906142f0565b613215565b90505b92915050565b600080611ed1611ec38461331a565b611ecc85612b61565b612c8a565b905060008360060160009054906101000a90046001600160a01b031690506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5391906142f0565b90508015611f855780611f686012600a6145ab565b611f7290856143c5565b611f7c91906143dc565b95945050505050565b506000949350505050565b6402540be400811115611fe55760405162461bcd60e51b815260206004820152600f60248201527f46656520697320746f6f20686967680000000000000000000000000000000000604482015260640161039e565b600582018190556040518181527fab599d640ca80cde2b09b128a4154a8dfe608cb80f4c9399c8b954b01fd35f3890602001610d2a565b600080866007018660ff168154811061203757612037614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116915081906370a0823190602401602060405180830381865afa1580156120a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c891906142f0565b8411156121175760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073776170206d6f7265207468616e20796f75206f776e000000604482015260640161039e565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015612177573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219b91906142f0565b90506121b26001600160a01b038316333088612e5f565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015612211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223591906142f0565b61223f9190614367565b9450505060008060008860090180548060200260200160405190810160405280929190818152602001828054801561229657602002820191906000526020600020905b815481526020019060010190808311612282575b505050505090506122aa8989898985612ff6565b9093509150848310156122ff5760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e73604482015260640161039e565b6000896008018860ff168154811061231957612319614309565b90600052602060002001546402540be4008b600501548561233a91906143c5565b61234491906143dc565b61234e91906143dc565b905086828a60ff168151811061236657612366614309565b6020026020010151612378919061437a565b8a6009018a60ff168154811061239057612390614309565b90600052602060002001819055508084838a60ff16815181106123b5576123b5614309565b60200260200101516123c79190614367565b6123d19190614367565b8a6009018960ff16815481106123e9576123e9614309565b906000526020600020018190555061243033858c6007018b60ff168154811061241457612414614309565b6000918252602090912001546001600160a01b031691906131c7565b604080518881526020810186905260ff8b8116828401528a166060820152905133917fc6c1e0630dbe9130cc068028486c0d118ddcea348550819defd5cb8c257f8a38919081900360800190a2509198975050505050505050565b600782015460009082106124e15760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b8260090182815481106124f6576124f6614309565b906000526020600020015483600701838154811061251657612516614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a491906142f0565b611eab9190614367565b6006840154600785018054604080516020808402820181019092528281526060946001600160a01b031693600093919290919083018282801561261a57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116125fc575b50506040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015293945050506001600160a01b038416916370a082319150602401602060405180830381865afa15801561267f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a391906142f0565b8611156126f25760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b805184146127425760405162461bcd60e51b815260206004820181905260248201527f6d696e416d6f756e7473206d757374206d6174636820706f6f6c546f6b656e73604482015260640161039e565b60008760090180548060200260200160405190810160405280929190818152602001828054801561279257602002820191906000526020600020905b81548152602001906001019080831161277e575b505050505090506000836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fd91906142f0565b9050600061280c838a84613215565b905060005b81518110156129245788888281811061282c5761282c614309565b9050602002013582828151811061284557612845614309565b6020026020010151101561289b5760405162461bcd60e51b815260206004820152601a60248201527f616d6f756e74735b695d203c206d696e416d6f756e74735b695d000000000000604482015260640161039e565b8181815181106128ad576128ad614309565b60200260200101518482815181106128c7576128c7614309565b60200260200101516128d99190614367565b8b60090182815481106128ee576128ee614309565b90600052602060002001819055506129123383838151811061165257611652614309565b8061291c8161438d565b915050612811565b506040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b15801561298657600080fd5b505af115801561299a573d6000803e3d6000fd5b503392507f88d38ed598fdd809c2bf01ee49cd24b7fdabf379a83d29567952b60324d58cef91508390506129ce8c86614367565b6040516129dc9291906145b7565b60405180910390a29998505050505050505050565b600082600701805480602002602001604051908101604052809291908181526020018280548015612a4b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a2d575b5050505050905060005b8151811015612b5b576000828281518110612a7257612a72614309565b602002602001015190506000856009018381548110612a9357612a93614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa158015612afc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2091906142f0565b612b2a9190614367565b90508015612b4657612b466001600160a01b03831686836131c7565b50508080612b539061438d565b915050612a55565b50505050565b6000611eae826133ca565b81518151606091908114612bc25760405162461bcd60e51b815260206004820152601f60248201527f42616c616e636573206d757374206d61746368206d756c7469706c6965727300604482015260640161039e565b60008167ffffffffffffffff811115612bdd57612bdd613efd565b604051908082528060200260200182016040528015612c06578160200160208202803683370190505b50905060005b82811015612c8157848181518110612c2657612c26614309565b6020026020010151868281518110612c4057612c40614309565b6020026020010151612c5291906143c5565b828281518110612c6457612c64614309565b602090810291909101015280612c798161438d565b915050612c0c565b50949350505050565b815160009081805b82811015612cd357858181518110612cac57612cac614309565b602002602001015182612cbf919061437a565b915080612ccb8161438d565b915050612c92565b5080600003612ce757600092505050611eae565b60008181612cf585886143c5565b905060005b610100811015612e16578260005b87811015612d5d57878b8281518110612d2357612d23614309565b6020026020010151612d3591906143c5565b612d3f86846143c5565b612d4991906143dc565b915080612d558161438d565b915050612d08565b5083945080876001612d6f919061437a565b612d7991906143c5565b606485612d868287614367565b612d9091906143c5565b612d9a91906143dc565b612da4919061437a565b84612daf89846143c5565b6064612dbb8a886143c5565b612dc591906143dc565b612dcf919061437a565b612dd991906143c5565b612de391906143dc565b9350612def8486613471565b15612e035783975050505050505050611eae565b5080612e0e8161438d565b915050612cfa565b5060405162461bcd60e51b815260206004820152601360248201527f4420646f6573206e6f7420636f6e766572676500000000000000000000000000604482015260640161039e565b6040516001600160a01b0380851660248301528316604482015260648101829052612b5b9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613488565b6000612f3b600183614367565b612f469060046143c5565b612f5083856143c5565b611eab91906143dc565b600081831115612f7557612f6e8284614367565b9050611eae565b611eab8383614367565b6000806000806000612f9389888a8961356d565b8093508194508295505050506000838a6008018960ff1681548110612fba57612fba614309565b90600052602060002001548484612fd19190614367565b612fdb91906143dc565b612fe59190614367565b939a93995092975050505050505050565b60008060008760080180548060200260200160405190810160405280929190818152602001828054801561304957602002820191906000526020600020905b815481526020019060010190808311613035575b50505050509050600061305c8583612b6c565b905080518860ff16108015613074575080518760ff16105b6130c05760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b6000818960ff16815181106130d7576130d7614309565b6020026020010151838a60ff16815181106130f4576130f4614309565b60200260200101518861310791906143c5565b613111919061437a565b9050600061312a6131218c612b61565b8b8b85876138be565b9050600181848b60ff168151811061314457613144614309565b60200260200101516131569190614367565b6131609190614367565b95506402540be4008b600401548761317891906143c5565b61318291906143dc565b9450838960ff168151811061319957613199614309565b602002602001015185876131ad9190614367565b6131b791906143dc565b9550505050509550959350505050565b6040516001600160a01b0383166024820152604481018290526132109084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612eac565b505050565b6060818311156132675760405162461bcd60e51b815260206004820152601a60248201527f43616e6e6f742065786365656420746f74616c20737570706c79000000000000604482015260640161039e565b6000845167ffffffffffffffff81111561328357613283613efd565b6040519080825280602002602001820160405280156132ac578160200160208202803683370190505b50905060005b8551811015612c815783858783815181106132cf576132cf614309565b60200260200101516132e191906143c5565b6132eb91906143dc565b8282815181106132fd576132fd614309565b6020908102919091010152806133128161438d565b9150506132b2565b6060611eae8260090180548060200260200160405190810160405280929190818152602001828054801561336d57602002820191906000526020600020905b815481526020019060010190808311613359575b5050505050836008018054806020026020016040519081016040528092919081815260200182805480156133c057602002820191906000526020600020905b8154815260200190600101908083116133ac575b5050505050612b6c565b600381015460018201546000919042821115610c9c576002840154845480831115613435576133f98285614367565b6134038342614367565b61340d8386614367565b61341791906143c5565b61342191906143dc565b61342b908261437a565b9695505050505050565b61343f8285614367565b6134498342614367565b6134538584614367565b61345d91906143c5565b61346791906143dc565b61342b9082614367565b6000600161347f8484612f5a565b11159392505050565b60006134dd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613b459092919063ffffffff16565b80519091501561321057808060200190518101906134fb91906145d9565b6132105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161039e565b60008060008061357c8861331a565b905080518760ff16106135d15760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b60006040518060a00160405280600081526020016000815260200160008152602001600081526020016000815250905061360a89612b61565b6080820181905261361c908390612c8a565b808252869061362b90896143c5565b61363591906143dc565b81516136419190614367565b60208201528151829060ff8a1690811061365d5761365d614309565b60200260200101518711156136b45760405162461bcd60e51b815260206004820152601a60248201527f5769746864726177206578636565647320617661696c61626c65000000000000604482015260640161039e565b6136c8816080015189848460200151613b54565b6040820152815160009067ffffffffffffffff8111156136ea576136ea613efd565b604051908082528060200260200182016040528015613713578160200160208202803683370190505b5090506137258a600401548451612f2e565b606083015260005b835181101561380b57600084828151811061374a5761374a614309565b602002602001015190506402540be40084606001518c60ff168414613793578551602087015161377a90856143c5565b61378491906143dc565b61378e9084614367565b6137bd565b6040860151865160208801516137a990866143c5565b6137b391906143dc565b6137bd9190614367565b6137c791906143c5565b6137d191906143dc565b6137db9082614367565b8383815181106137ed576137ed614309565b602090810291909101015250806138038161438d565b91505061372d565b50600061382283608001518b848660200151613b54565b828b60ff168151811061383757613837614309565b60200260200101516138499190614367565b90508a6008018a60ff168154811061386357613863614309565b906000526020600020015460018261387b9190614367565b61388591906143dc565b9050808360400151858c60ff16815181106138a2576138a2614309565b6020026020010151965096509650505050509450945094915050565b805160009060ff808616908716036139185760405162461bcd60e51b815260206004820152601d60248201527f43616e277420636f6d7061726520746f6b656e20746f20697473656c66000000604482015260640161039e565b808660ff1610801561392c5750808560ff16105b6139785760405162461bcd60e51b815260206004820152601660248201527f546f6b656e73206d75737420626520696e20706f6f6c00000000000000000000604482015260640161039e565b60006139848489612c8a565b9050806000806139948b866143c5565b90506000805b86811015613a23578b60ff1681036139b4578991506139e4565b8a60ff1681146139df578881815181106139d0576139d0614309565b602002602001015191506139e4565b613a11565b6139ee828561437a565b93506139fa87836143c5565b613a0487876143c5565b613a0e91906143dc565b94505b80613a1b8161438d565b91505061399a565b50613a2e86836143c5565b6064613a3a87876143c5565b613a4491906143c5565b613a4e91906143dc565b9350600082613a5e6064886143c5565b613a6891906143dc565b613a72908561437a565b9050600086815b610100811015613afc578192508884836002613a9591906143c5565b613a9f919061437a565b613aa99190614367565b88613ab484806143c5565b613abe919061437a565b613ac891906143dc565b9150613ad48284613471565b15613aea57509850611f7c975050505050505050565b80613af48161438d565b915050613a79565b5060405162461bcd60e51b815260206004820152601e60248201527f417070726f78696d6174696f6e20646964206e6f7420636f6e76657267650000604482015260640161039e565b6060611a068484600085613d1c565b815160009060ff85168111613bab5760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e640000000000000000000000000000000000604482015260640161039e565b82600080613bb9848a6143c5565b905060005b84811015613c45578860ff168114613c3357878181518110613be257613be2614309565b602002602001015183613bf5919061437a565b925084888281518110613c0a57613c0a614309565b6020026020010151613c1c91906143c5565b613c2688866143c5565b613c3091906143dc565b93505b80613c3d8161438d565b915050613bbe565b50613c5084826143c5565b6064613c5c88866143c5565b613c6691906143c5565b613c7091906143dc565b9250600081613c806064896143c5565b613c8a91906143dc565b613c94908461437a565b9050600087815b610100811015613afc578192508984836002613cb791906143c5565b613cc1919061437a565b613ccb9190614367565b87613cd684806143c5565b613ce0919061437a565b613cea91906143dc565b9150613cf68284613471565b15613d0a57509650611a0695505050505050565b80613d148161438d565b915050613c9b565b606082471015613d945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161039e565b6001600160a01b0385163b613deb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161039e565b600080866001600160a01b03168587604051613e07919061461a565b60006040518083038185875af1925050503d8060008114613e44576040519150601f19603f3d011682016040523d82523d6000602084013e613e49565b606091505b5091509150613e59828286613e64565b979650505050505050565b60608315613e73575081610c9c565b825115613e835782518084602001fd5b8160405162461bcd60e51b815260040161039e9190614636565b828054828255906000526020600020908101928215613ed8579160200282015b82811115613ed8578251825591602001919060010190613ebd565b50613ee4929150613ee8565b5090565b5b80821115613ee45760008155600101613ee9565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080600060608486031215613f4157600080fd5b8335925060208085013567ffffffffffffffff80821115613f6157600080fd5b818701915087601f830112613f7557600080fd5b813581811115613f8757613f87613efd565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715613fca57613fca613efd565b60405291825284820192508381018501918a831115613fe857600080fd5b938501935b8285101561400657843584529385019392850192613fed565b979a979950505050604095909501359450505050565b6000806040838503121561402f57600080fd5b50508035926020909101359150565b803560ff8116811461404f57600080fd5b919050565b60008060006060848603121561406957600080fd5b83359250602084013591506140806040850161403e565b90509250925092565b6000806000806080858703121561409f57600080fd5b843593506140af6020860161403e565b92506140bd6040860161403e565b9396929550929360600135925050565b60008083601f8401126140df57600080fd5b50813567ffffffffffffffff8111156140f757600080fd5b6020830191508360208260051b850101111561411257600080fd5b9250929050565b801515811461412757600080fd5b50565b6000806000806060858703121561414057600080fd5b84359350602085013567ffffffffffffffff81111561415e57600080fd5b61416a878288016140cd565b909450925050604085013561417e81614119565b939692955090935050565b6000806000806080858703121561419f57600080fd5b84359350602085013592506140bd6040860161403e565b6020808252825182820181905260009190848201906040850190845b818110156141ee578351835292840192918401916001016141d2565b50909695505050505050565b60006020828403121561420c57600080fd5b5035919050565b600080600080600060a0868803121561422b57600080fd5b8535945061423b6020870161403e565b93506142496040870161403e565b94979396509394606081013594506080013592915050565b6000806000806060858703121561427757600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561429c57600080fd5b6142a8878288016140cd565b95989497509550505050565b600080604083850312156142c757600080fd5b8235915060208301356001600160a01b03811681146142e557600080fd5b809150509250929050565b60006020828403121561430257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611eae57611eae614338565b80820180821115611eae57611eae614338565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036143be576143be614338565b5060010190565b8082028115828204841417611eae57611eae614338565b600082614412577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600081518084526020808501945080840160005b838110156144475781518752958201959082019060010161442b565b509495945050505050565b6080815260006144656080830187614417565b82810360208401526144778187614417565b604084019590955250506060015292915050565b600181815b808511156144e457817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156144ca576144ca614338565b808516156144d757918102915b93841c9390800290614490565b509250929050565b6000826144fb57506001611eae565b8161450857506000611eae565b816001811461451e576002811461452857614544565b6001915050611eae565b60ff84111561453957614539614338565b50506001821b611eae565b5060208310610133831016604e8410600b8410161715614567575081810a611eae565b614571838361448b565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156145a3576145a3614338565b029392505050565b6000611eab83836144ec565b6040815260006145ca6040830185614417565b90508260208301529392505050565b6000602082840312156145eb57600080fd5b8151610c9c81614119565b60005b838110156146115781810151838201526020016145f9565b50506000910152565b6000825161462c8184602087016145f6565b9190910192915050565b60208152600082518060208401526146558160408501602087016145f6565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122063f345701b169dc81c247231632173bffc7cc60aec27e9bcf19213b2eadb399064736f6c63430008110033", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106101255760003560e01c80638424905f116100bc578063acf914781161008b578063f3de036211610070578063f3de0362146102a3578063fa76ee2a146102af578063fe7cb1c0146102cf57600080fd5b8063acf9147814610270578063cbc7f8dd1461029057600080fd5b80638424905f1461021257806398a20a3e14610232578063a125d92414610245578063ab3d85441461026557600080fd5b806339e43af2116100f857806339e43af2146101ac5780634540fb7f146101bf5780636972fae8146101df578063711cd330146101f257600080fd5b80630296ab501461012a578063041894b01461014957806305f7ec21146101775780631a535da514610199575b600080fd5b610132601281565b60405160ff90911681526020015b60405180910390f35b81801561015557600080fd5b50610169610164366004613f2c565b6102ef565b604051908152602001610140565b81801561018357600080fd5b5061019761019236600461401c565b610ca3565b005b6101696101a7366004614054565b610d36565b6101696101ba366004614089565b610dc7565b8180156101cb57600080fd5b506101696101da366004613f2c565b610e28565b6101696101ed36600461412a565b6116e1565b8180156101fe57600080fd5b5061016961020d366004614189565b611a0e565b61022561022036600461401c565b611dd4565b60405161014091906141b6565b6101696102403660046141fa565b611eb4565b81801561025157600080fd5b5061019761026036600461401c565b611f90565b6101696305f5e10081565b81801561027c57600080fd5b5061016961028b366004614213565b61201c565b61016961029e36600461401c565b61248b565b6101696402540be40081565b8180156102bb57600080fd5b506102256102ca366004614261565b6125ae565b8180156102db57600080fd5b506101976102ea3660046142b4565b6129f1565b6000808460070180548060200260200160405190810160405280929190818152602001828054801561034a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161032c575b5050505050905080518451146103a75760405162461bcd60e51b815260206004820181905260248201527f416d6f756e7473206d757374206d6174636820706f6f6c656420746f6b656e7360448201526064015b60405180910390fd5b60006040518061010001604052806000815260200160008152602001600081526020016103d388612b61565b81526020018760060160009054906101000a90046001600160a01b03166001600160a01b03168152602001600081526020018760090180548060200260200160405190810160405280929190818152602001828054801561045357602002820191906000526020600020905b81548152602001906001019080831161043f575b50505050508152602001876008018054806020026020016040519081016040528092919081815260200182805480156104ab57602002820191906000526020600020905b815481526020019060010190808311610497575b5050505050815250905080608001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051b91906142f0565b60a08201819052156105495761054661053c8260c001518360e00151612b6c565b8260600151612c8a565b81525b6000825167ffffffffffffffff81111561056557610565613efd565b60405190808252806020026020018201604052801561058e578160200160208202803683370190505b50905060005b83518110156108655760a08301511515806105c8575060008782815181106105be576105be614309565b6020026020010151115b6106145760405162461bcd60e51b815260206004820152601e60248201527f4d75737420737570706c7920616c6c20746f6b656e7320696e20706f6f6c0000604482015260640161039e565b86818151811061062657610626614309565b60200260200101516000146107f457600084828151811061064957610649614309565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d691906142f0565b905061072a33308a85815181106106ef576106ef614309565b602002602001015188868151811061070957610709614309565b60200260200101516001600160a01b0316612e5f909392919063ffffffff16565b8085838151811061073d5761073d614309565b60209081029190910101516040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156107a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ca91906142f0565b6107d49190614367565b8883815181106107e6576107e6614309565b602002602001018181525050505b86818151811061080657610806614309565b60200260200101518360c00151828151811061082457610824614309565b6020026020010151610836919061437a565b82828151811061084857610848614309565b60209081029190910101528061085d8161438d565b915050610594565b50610881610877828460e00151612b6c565b8360600151612c8a565b602083018190528251106108d75760405162461bcd60e51b815260206004820152601160248201527f442073686f756c6420696e637265617365000000000000000000000000000000604482015260640161039e565b60208201516040830152825160009067ffffffffffffffff8111156108fe576108fe613efd565b604051908082528060200260200182016040528015610927578160200160208202803683370190505b5090508260a00151600014610b0e57600061094789600401548651612f2e565b905060005b8551811015610ae757600085600001518660c00151838151811061097257610972614309565b6020026020010151876020015161098991906143c5565b61099391906143dc565b90506402540be4006109c78684815181106109b0576109b0614309565b602002602001015183612f5a90919063ffffffff16565b6109d190856143c5565b6109db91906143dc565b8483815181106109ed576109ed614309565b6020026020010181815250506402540be4008b60050154858481518110610a1657610a16614309565b6020026020010151610a2891906143c5565b610a3291906143dc565b858381518110610a4457610a44614309565b6020026020010151610a569190614367565b8b6009018381548110610a6b57610a6b614309565b9060005260206000200181905550838281518110610a8b57610a8b614309565b6020026020010151858381518110610aa557610aa5614309565b6020026020010151610ab79190614367565b858381518110610ac957610ac9614309565b60209081029190910101525080610adf8161438d565b91505061094c565b50610b03610af9848660e00151612b6c565b8560600151612c8a565b604085015250610b25565b8151610b239060098a01906020850190613e9d565b505b60008360a00151600003610b3e57506020830151610b6c565b835160a08501516040860151610b55908390614367565b610b5f91906143c5565b610b6991906143dc565b90505b86811015610bbc5760405162461bcd60e51b815260206004820152601b60248201527f436f756c646e2774206d696e74206d696e207265717565737465640000000000604482015260640161039e565b60808401516040517f40c10f19000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b158015610c2357600080fd5b505af1158015610c37573d6000803e3d6000fd5b50505050336001600160a01b03167f189c623b666b1b45b83d7178f39b8c087cb09774317ca2f53c2d3c3726f222a289848760200151858960a00151610c7d919061437a565b604051610c8d9493929190614452565b60405180910390a29450505050505b9392505050565b6305f5e100811115610cf75760405162461bcd60e51b815260206004820152600f60248201527f46656520697320746f6f20686967680000000000000000000000000000000000604482015260640161039e565b600482018190556040518181527fd88ea5155021c6f8dafa1a741e173f595cdf77ce7c17d43342131d7f06afdfe5906020015b60405180910390a15050565b600080610dbd8585858860060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db891906142f0565b612f7f565b5095945050505050565b6000610dbd8585858589600901805480602002602001604051908101604052809291908181526020018280548015610e1e57602002820191906000526020600020905b815481526020019060010190808311610e0a575b5050505050612ff6565b600080604051806101000160405280600081526020016000815260200160008152602001610e5587612b61565b81526020018660060160009054906101000a90046001600160a01b03166001600160a01b031681526020016000815260200186600901805480602002602001604051908101604052809291908181526020018280548015610ed557602002820191906000526020600020905b815481526020019060010190808311610ec1575b5050505050815260200186600801805480602002602001604051908101604052809291908181526020018280548015610f2d57602002820191906000526020600020905b815481526020019060010190808311610f19575b5050505050815250905080608001516001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9d91906142f0565b60a08201526007850180546040805160208084028201810190925282815260009390929091830182828015610ffb57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fdd575b5050505050905080518551146110535760405162461bcd60e51b815260206004820181905260248201527f416d6f756e74732073686f756c64206d6174636820706f6f6c20746f6b656e73604482015260640161039e565b60808201516040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156110b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110da91906142f0565b84111580156110e857508315155b6111345760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b600061114587600401548351612f2e565b90506000825167ffffffffffffffff81111561116357611163613efd565b60405190808252806020026020018201604052801561118c578160200160208202803683370190505b5090506000835167ffffffffffffffff8111156111ab576111ab613efd565b6040519080825280602002602001820160405280156111d4578160200160208202803683370190505b5090506111f66111ec8660c001518760e00151612b6c565b8660600151612c8a565b855260005b8451811015611319578560c00151818151811061121a5761121a614309565b602002602001015189828151811061123457611234614309565b602002602001015111156112b05760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c650000000000000000000000000000000000000000000000000000000000606482015260840161039e565b8881815181106112c2576112c2614309565b60200260200101518660c0015182815181106112e0576112e0614309565b6020026020010151038282815181106112fb576112fb614309565b602002602001018181525050806113118161438d565b9150506111fb565b5061132b6111ec828760e00151612b6c565b602086015260005b84518110156114be57600086600001518760c00151838151811061135957611359614309565b6020026020010151886020015161137091906143c5565b61137a91906143dc565b905060006113938484815181106109b0576109b0614309565b90506402540be4006113a582886143c5565b6113af91906143dc565b8584815181106113c1576113c1614309565b6020026020010181815250506402540be4008c600501548685815181106113ea576113ea614309565b60200260200101516113fc91906143c5565b61140691906143dc565b84848151811061141857611418614309565b602002602001015161142a9190614367565b8c600901848154811061143f5761143f614309565b906000526020600020018190555084838151811061145f5761145f614309565b602002602001015184848151811061147957611479614309565b602002602001015161148b9190614367565b84848151811061149d5761149d614309565b602002602001018181525050505080806114b69061438d565b915050611333565b506114d06111ec828760e00151612b6c565b60408601819052855160a08701516000935090916114ee9083614367565b6114f891906143c5565b61150291906143dc565b9050806000036115545760405162461bcd60e51b815260206004820152601b60248201527f4275726e7420616d6f756e742063616e6e6f74206265207a65726f0000000000604482015260640161039e565b61155f81600161437a565b9050868111156115b15760405162461bcd60e51b815260206004820152601b60248201527f746f6b656e416d6f756e74203e206d61784275726e416d6f756e740000000000604482015260640161039e565b60808501516040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561161857600080fd5b505af115801561162c573d6000803e3d6000fd5b5050505060005b845181101561169e5761168c338a838151811061165257611652614309565b602002602001015187848151811061166c5761166c614309565b60200260200101516001600160a01b03166131c79092919063ffffffff16565b806116968161438d565b915050611633565b50336001600160a01b03167f3631c28b1f9dd213e0319fb167b554d76b6c283a41143eb400a0d1adb1af175589848860200151858a60a00151610c7d9190614367565b6000806116ed86612b61565b905060008660090180548060200260200160405190810160405280929190818152602001828054801561173f57602002820191906000526020600020905b81548152602001906001019080831161172b575b5050505050905060008760080180548060200260200160405190810160405280929190818152602001828054801561179657602002820191906000526020600020905b815481526020019060010190808311611782575b5050505050905060006117b26117ac8484612b6c565b85612c8a565b905060005b8351811015611932578615611826578888828181106117d8576117d8614309565b905060200201358482815181106117f1576117f1614309565b6020026020010151611803919061437a565b84828151811061181557611815614309565b602002602001018181525050611920565b83818151811061183857611838614309565b602002602001015189898381811061185257611852614309565b9050602002013511156118cd5760405162461bcd60e51b815260206004820152602360248201527f43616e6e6f74207769746864726177206d6f7265207468616e20617661696c6160448201527f626c650000000000000000000000000000000000000000000000000000000000606482015260840161039e565b8888828181106118df576118df614309565b905060200201358482815181106118f8576118f8614309565b60200260200101510384828151811061191357611913614309565b6020026020010181815250505b8061192a8161438d565b9150506117b7565b5060006119486119428585612b6c565b86612c8a565b905060008a60060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c591906142f0565b905087156119fa5782816119d98285614367565b6119e391906143c5565b6119ed91906143dc565b9650505050505050611a06565b82816119d98483614367565b949350505050565b6006840154600785018054604080516020808402820181019092528281526000946001600160a01b03169385939192909190830182828015611a7957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a5b575b50506040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015293945050506001600160a01b038416916370a082319150602401602060405180830381865afa158015611ade573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0291906142f0565b861115611b515760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b80518560ff1610611ba45760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e640000000000000000000000000000000000604482015260640161039e565b6000826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611be4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0891906142f0565b9050600080611c198a8a8a86612f7f565b9150915086821015611c6d5760405162461bcd60e51b815260206004820152600e60248201527f6479203c206d696e416d6f756e74000000000000000000000000000000000000604482015260640161039e565b6402540be4008a6005015482611c8391906143c5565b611c8d91906143dc565b611c97908361437a565b8a6009018960ff1681548110611caf57611caf614309565b9060005260206000200154611cc49190614367565b8a6009018960ff1681548110611cdc57611cdc614309565b6000918252602090912001556040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b158015611d4957600080fd5b505af1158015611d5d573d6000803e3d6000fd5b50505050611d7b3383868b60ff168151811061166c5761166c614309565b604080518a81526020810185905260ff8a168183015260608101849052905133917f43fb02998f4e03da2e0e6fff53fdbf0c40a9f45f145dc377fc30615d7d7a8a64919081900360800190a25098975050505050505050565b6060611eab83600901805480602002602001604051908101604052809291908181526020018280548015611e2757602002820191906000526020600020905b815481526020019060010190808311611e13575b5050505050838560060160009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ea691906142f0565b613215565b90505b92915050565b600080611ed1611ec38461331a565b611ecc85612b61565b612c8a565b905060008360060160009054906101000a90046001600160a01b031690506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5391906142f0565b90508015611f855780611f686012600a6145ab565b611f7290856143c5565b611f7c91906143dc565b95945050505050565b506000949350505050565b6402540be400811115611fe55760405162461bcd60e51b815260206004820152600f60248201527f46656520697320746f6f20686967680000000000000000000000000000000000604482015260640161039e565b600582018190556040518181527fab599d640ca80cde2b09b128a4154a8dfe608cb80f4c9399c8b954b01fd35f3890602001610d2a565b600080866007018660ff168154811061203757612037614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116915081906370a0823190602401602060405180830381865afa1580156120a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c891906142f0565b8411156121175760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f742073776170206d6f7265207468616e20796f75206f776e000000604482015260640161039e565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015612177573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219b91906142f0565b90506121b26001600160a01b038316333088612e5f565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015612211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223591906142f0565b61223f9190614367565b9450505060008060008860090180548060200260200160405190810160405280929190818152602001828054801561229657602002820191906000526020600020905b815481526020019060010190808311612282575b505050505090506122aa8989898985612ff6565b9093509150848310156122ff5760405162461bcd60e51b815260206004820181905260248201527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e73604482015260640161039e565b6000896008018860ff168154811061231957612319614309565b90600052602060002001546402540be4008b600501548561233a91906143c5565b61234491906143dc565b61234e91906143dc565b905086828a60ff168151811061236657612366614309565b6020026020010151612378919061437a565b8a6009018a60ff168154811061239057612390614309565b90600052602060002001819055508084838a60ff16815181106123b5576123b5614309565b60200260200101516123c79190614367565b6123d19190614367565b8a6009018960ff16815481106123e9576123e9614309565b906000526020600020018190555061243033858c6007018b60ff168154811061241457612414614309565b6000918252602090912001546001600160a01b031691906131c7565b604080518881526020810186905260ff8b8116828401528a166060820152905133917fc6c1e0630dbe9130cc068028486c0d118ddcea348550819defd5cb8c257f8a38919081900360800190a2509198975050505050505050565b600782015460009082106124e15760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b8260090182815481106124f6576124f6614309565b906000526020600020015483600701838154811061251657612516614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612580573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a491906142f0565b611eab9190614367565b6006840154600785018054604080516020808402820181019092528281526060946001600160a01b031693600093919290919083018282801561261a57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116125fc575b50506040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015293945050506001600160a01b038416916370a082319150602401602060405180830381865afa15801561267f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a391906142f0565b8611156126f25760405162461bcd60e51b815260206004820152600d60248201527f3e4c502e62616c616e63654f6600000000000000000000000000000000000000604482015260640161039e565b805184146127425760405162461bcd60e51b815260206004820181905260248201527f6d696e416d6f756e7473206d757374206d6174636820706f6f6c546f6b656e73604482015260640161039e565b60008760090180548060200260200160405190810160405280929190818152602001828054801561279257602002820191906000526020600020905b81548152602001906001019080831161277e575b505050505090506000836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127fd91906142f0565b9050600061280c838a84613215565b905060005b81518110156129245788888281811061282c5761282c614309565b9050602002013582828151811061284557612845614309565b6020026020010151101561289b5760405162461bcd60e51b815260206004820152601a60248201527f616d6f756e74735b695d203c206d696e416d6f756e74735b695d000000000000604482015260640161039e565b8181815181106128ad576128ad614309565b60200260200101518482815181106128c7576128c7614309565b60200260200101516128d99190614367565b8b60090182815481106128ee576128ee614309565b90600052602060002001819055506129123383838151811061165257611652614309565b8061291c8161438d565b915050612811565b506040517f79cc6790000000000000000000000000000000000000000000000000000000008152336004820152602481018a90526001600160a01b038616906379cc679090604401600060405180830381600087803b15801561298657600080fd5b505af115801561299a573d6000803e3d6000fd5b503392507f88d38ed598fdd809c2bf01ee49cd24b7fdabf379a83d29567952b60324d58cef91508390506129ce8c86614367565b6040516129dc9291906145b7565b60405180910390a29998505050505050505050565b600082600701805480602002602001604051908101604052809291908181526020018280548015612a4b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a2d575b5050505050905060005b8151811015612b5b576000828281518110612a7257612a72614309565b602002602001015190506000856009018381548110612a9357612a93614309565b6000918252602090912001546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa158015612afc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b2091906142f0565b612b2a9190614367565b90508015612b4657612b466001600160a01b03831686836131c7565b50508080612b539061438d565b915050612a55565b50505050565b6000611eae826133ca565b81518151606091908114612bc25760405162461bcd60e51b815260206004820152601f60248201527f42616c616e636573206d757374206d61746368206d756c7469706c6965727300604482015260640161039e565b60008167ffffffffffffffff811115612bdd57612bdd613efd565b604051908082528060200260200182016040528015612c06578160200160208202803683370190505b50905060005b82811015612c8157848181518110612c2657612c26614309565b6020026020010151868281518110612c4057612c40614309565b6020026020010151612c5291906143c5565b828281518110612c6457612c64614309565b602090810291909101015280612c798161438d565b915050612c0c565b50949350505050565b815160009081805b82811015612cd357858181518110612cac57612cac614309565b602002602001015182612cbf919061437a565b915080612ccb8161438d565b915050612c92565b5080600003612ce757600092505050611eae565b60008181612cf585886143c5565b905060005b610100811015612e16578260005b87811015612d5d57878b8281518110612d2357612d23614309565b6020026020010151612d3591906143c5565b612d3f86846143c5565b612d4991906143dc565b915080612d558161438d565b915050612d08565b5083945080876001612d6f919061437a565b612d7991906143c5565b606485612d868287614367565b612d9091906143c5565b612d9a91906143dc565b612da4919061437a565b84612daf89846143c5565b6064612dbb8a886143c5565b612dc591906143dc565b612dcf919061437a565b612dd991906143c5565b612de391906143dc565b9350612def8486613471565b15612e035783975050505050505050611eae565b5080612e0e8161438d565b915050612cfa565b5060405162461bcd60e51b815260206004820152601360248201527f4420646f6573206e6f7420636f6e766572676500000000000000000000000000604482015260640161039e565b6040516001600160a01b0380851660248301528316604482015260648101829052612b5b9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613488565b6000612f3b600183614367565b612f469060046143c5565b612f5083856143c5565b611eab91906143dc565b600081831115612f7557612f6e8284614367565b9050611eae565b611eab8383614367565b6000806000806000612f9389888a8961356d565b8093508194508295505050506000838a6008018960ff1681548110612fba57612fba614309565b90600052602060002001548484612fd19190614367565b612fdb91906143dc565b612fe59190614367565b939a93995092975050505050505050565b60008060008760080180548060200260200160405190810160405280929190818152602001828054801561304957602002820191906000526020600020905b815481526020019060010190808311613035575b50505050509050600061305c8583612b6c565b905080518860ff16108015613074575080518760ff16105b6130c05760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b6000818960ff16815181106130d7576130d7614309565b6020026020010151838a60ff16815181106130f4576130f4614309565b60200260200101518861310791906143c5565b613111919061437a565b9050600061312a6131218c612b61565b8b8b85876138be565b9050600181848b60ff168151811061314457613144614309565b60200260200101516131569190614367565b6131609190614367565b95506402540be4008b600401548761317891906143c5565b61318291906143dc565b9450838960ff168151811061319957613199614309565b602002602001015185876131ad9190614367565b6131b791906143dc565b9550505050509550959350505050565b6040516001600160a01b0383166024820152604481018290526132109084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401612eac565b505050565b6060818311156132675760405162461bcd60e51b815260206004820152601a60248201527f43616e6e6f742065786365656420746f74616c20737570706c79000000000000604482015260640161039e565b6000845167ffffffffffffffff81111561328357613283613efd565b6040519080825280602002602001820160405280156132ac578160200160208202803683370190505b50905060005b8551811015612c815783858783815181106132cf576132cf614309565b60200260200101516132e191906143c5565b6132eb91906143dc565b8282815181106132fd576132fd614309565b6020908102919091010152806133128161438d565b9150506132b2565b6060611eae8260090180548060200260200160405190810160405280929190818152602001828054801561336d57602002820191906000526020600020905b815481526020019060010190808311613359575b5050505050836008018054806020026020016040519081016040528092919081815260200182805480156133c057602002820191906000526020600020905b8154815260200190600101908083116133ac575b5050505050612b6c565b600381015460018201546000919042821115610c9c576002840154845480831115613435576133f98285614367565b6134038342614367565b61340d8386614367565b61341791906143c5565b61342191906143dc565b61342b908261437a565b9695505050505050565b61343f8285614367565b6134498342614367565b6134538584614367565b61345d91906143c5565b61346791906143dc565b61342b9082614367565b6000600161347f8484612f5a565b11159392505050565b60006134dd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613b459092919063ffffffff16565b80519091501561321057808060200190518101906134fb91906145d9565b6132105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161039e565b60008060008061357c8861331a565b905080518760ff16106135d15760405162461bcd60e51b815260206004820152601860248201527f546f6b656e20696e646578206f7574206f662072616e67650000000000000000604482015260640161039e565b60006040518060a00160405280600081526020016000815260200160008152602001600081526020016000815250905061360a89612b61565b6080820181905261361c908390612c8a565b808252869061362b90896143c5565b61363591906143dc565b81516136419190614367565b60208201528151829060ff8a1690811061365d5761365d614309565b60200260200101518711156136b45760405162461bcd60e51b815260206004820152601a60248201527f5769746864726177206578636565647320617661696c61626c65000000000000604482015260640161039e565b6136c8816080015189848460200151613b54565b6040820152815160009067ffffffffffffffff8111156136ea576136ea613efd565b604051908082528060200260200182016040528015613713578160200160208202803683370190505b5090506137258a600401548451612f2e565b606083015260005b835181101561380b57600084828151811061374a5761374a614309565b602002602001015190506402540be40084606001518c60ff168414613793578551602087015161377a90856143c5565b61378491906143dc565b61378e9084614367565b6137bd565b6040860151865160208801516137a990866143c5565b6137b391906143dc565b6137bd9190614367565b6137c791906143c5565b6137d191906143dc565b6137db9082614367565b8383815181106137ed576137ed614309565b602090810291909101015250806138038161438d565b91505061372d565b50600061382283608001518b848660200151613b54565b828b60ff168151811061383757613837614309565b60200260200101516138499190614367565b90508a6008018a60ff168154811061386357613863614309565b906000526020600020015460018261387b9190614367565b61388591906143dc565b9050808360400151858c60ff16815181106138a2576138a2614309565b6020026020010151965096509650505050509450945094915050565b805160009060ff808616908716036139185760405162461bcd60e51b815260206004820152601d60248201527f43616e277420636f6d7061726520746f6b656e20746f20697473656c66000000604482015260640161039e565b808660ff1610801561392c5750808560ff16105b6139785760405162461bcd60e51b815260206004820152601660248201527f546f6b656e73206d75737420626520696e20706f6f6c00000000000000000000604482015260640161039e565b60006139848489612c8a565b9050806000806139948b866143c5565b90506000805b86811015613a23578b60ff1681036139b4578991506139e4565b8a60ff1681146139df578881815181106139d0576139d0614309565b602002602001015191506139e4565b613a11565b6139ee828561437a565b93506139fa87836143c5565b613a0487876143c5565b613a0e91906143dc565b94505b80613a1b8161438d565b91505061399a565b50613a2e86836143c5565b6064613a3a87876143c5565b613a4491906143c5565b613a4e91906143dc565b9350600082613a5e6064886143c5565b613a6891906143dc565b613a72908561437a565b9050600086815b610100811015613afc578192508884836002613a9591906143c5565b613a9f919061437a565b613aa99190614367565b88613ab484806143c5565b613abe919061437a565b613ac891906143dc565b9150613ad48284613471565b15613aea57509850611f7c975050505050505050565b80613af48161438d565b915050613a79565b5060405162461bcd60e51b815260206004820152601e60248201527f417070726f78696d6174696f6e20646964206e6f7420636f6e76657267650000604482015260640161039e565b6060611a068484600085613d1c565b815160009060ff85168111613bab5760405162461bcd60e51b815260206004820152600f60248201527f546f6b656e206e6f7420666f756e640000000000000000000000000000000000604482015260640161039e565b82600080613bb9848a6143c5565b905060005b84811015613c45578860ff168114613c3357878181518110613be257613be2614309565b602002602001015183613bf5919061437a565b925084888281518110613c0a57613c0a614309565b6020026020010151613c1c91906143c5565b613c2688866143c5565b613c3091906143dc565b93505b80613c3d8161438d565b915050613bbe565b50613c5084826143c5565b6064613c5c88866143c5565b613c6691906143c5565b613c7091906143dc565b9250600081613c806064896143c5565b613c8a91906143dc565b613c94908461437a565b9050600087815b610100811015613afc578192508984836002613cb791906143c5565b613cc1919061437a565b613ccb9190614367565b87613cd684806143c5565b613ce0919061437a565b613cea91906143dc565b9150613cf68284613471565b15613d0a57509650611a0695505050505050565b80613d148161438d565b915050613c9b565b606082471015613d945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161039e565b6001600160a01b0385163b613deb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161039e565b600080866001600160a01b03168587604051613e07919061461a565b60006040518083038185875af1925050503d8060008114613e44576040519150601f19603f3d011682016040523d82523d6000602084013e613e49565b606091505b5091509150613e59828286613e64565b979650505050505050565b60608315613e73575081610c9c565b825115613e835782518084602001fd5b8160405162461bcd60e51b815260040161039e9190614636565b828054828255906000526020600020908101928215613ed8579160200282015b82811115613ed8578251825591602001919060010190613ebd565b50613ee4929150613ee8565b5090565b5b80821115613ee45760008155600101613ee9565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080600060608486031215613f4157600080fd5b8335925060208085013567ffffffffffffffff80821115613f6157600080fd5b818701915087601f830112613f7557600080fd5b813581811115613f8757613f87613efd565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715613fca57613fca613efd565b60405291825284820192508381018501918a831115613fe857600080fd5b938501935b8285101561400657843584529385019392850192613fed565b979a979950505050604095909501359450505050565b6000806040838503121561402f57600080fd5b50508035926020909101359150565b803560ff8116811461404f57600080fd5b919050565b60008060006060848603121561406957600080fd5b83359250602084013591506140806040850161403e565b90509250925092565b6000806000806080858703121561409f57600080fd5b843593506140af6020860161403e565b92506140bd6040860161403e565b9396929550929360600135925050565b60008083601f8401126140df57600080fd5b50813567ffffffffffffffff8111156140f757600080fd5b6020830191508360208260051b850101111561411257600080fd5b9250929050565b801515811461412757600080fd5b50565b6000806000806060858703121561414057600080fd5b84359350602085013567ffffffffffffffff81111561415e57600080fd5b61416a878288016140cd565b909450925050604085013561417e81614119565b939692955090935050565b6000806000806080858703121561419f57600080fd5b84359350602085013592506140bd6040860161403e565b6020808252825182820181905260009190848201906040850190845b818110156141ee578351835292840192918401916001016141d2565b50909695505050505050565b60006020828403121561420c57600080fd5b5035919050565b600080600080600060a0868803121561422b57600080fd5b8535945061423b6020870161403e565b93506142496040870161403e565b94979396509394606081013594506080013592915050565b6000806000806060858703121561427757600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561429c57600080fd5b6142a8878288016140cd565b95989497509550505050565b600080604083850312156142c757600080fd5b8235915060208301356001600160a01b03811681146142e557600080fd5b809150509250929050565b60006020828403121561430257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115611eae57611eae614338565b80820180821115611eae57611eae614338565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036143be576143be614338565b5060010190565b8082028115828204841417611eae57611eae614338565b600082614412577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600081518084526020808501945080840160005b838110156144475781518752958201959082019060010161442b565b509495945050505050565b6080815260006144656080830187614417565b82810360208401526144778187614417565b604084019590955250506060015292915050565b600181815b808511156144e457817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156144ca576144ca614338565b808516156144d757918102915b93841c9390800290614490565b509250929050565b6000826144fb57506001611eae565b8161450857506000611eae565b816001811461451e576002811461452857614544565b6001915050611eae565b60ff84111561453957614539614338565b50506001821b611eae565b5060208310610133831016604e8410600b8410161715614567575081810a611eae565b614571838361448b565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156145a3576145a3614338565b029392505050565b6000611eab83836144ec565b6040815260006145ca6040830185614417565b90508260208301529392505050565b6000602082840312156145eb57600080fd5b8151610c9c81614119565b60005b838110156146115781810151838201526020016145f9565b50506000910152565b6000825161462c8184602087016145f6565b9190910192915050565b60208152600082518060208401526146558160408501602087016145f6565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122063f345701b169dc81c247231632173bffc7cc60aec27e9bcf19213b2eadb399064736f6c63430008110033", + "devdoc": { + "details": "Contracts relying on this library must initialize SwapUtils.Swap struct then use this library for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins. Admin functions should be protected within contracts using this library.", + "kind": "dev", + "methods": { + "addLiquidity(SwapUtilsV2.Swap storage,uint256[],uint256)": { + "params": { + "amounts": "the amounts of each token to add, in their native precision", + "minToMint": "the minimum LP tokens adding this amount of liquidity should mint, otherwise revert. Handy for front-running mitigation allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.", + "self": "Swap struct to read from and write to" + }, + "returns": { + "_0": "amount of LP token user received" + } + }, + "calculateRemoveLiquidity(SwapUtilsV2.Swap storage,uint256)": { + "params": { + "amount": "the amount of LP tokens that would to be burned on withdrawal" + }, + "returns": { + "_0": "array of amounts of tokens user will receive" + } + }, + "calculateSwap(SwapUtilsV2.Swap storage,uint8,uint8,uint256)": { + "params": { + "dx": "the number of tokens to sell. If the token charges a fee on transfers, use the amount that gets transferred after the fee.", + "self": "Swap struct to read from", + "tokenIndexFrom": "the token to sell", + "tokenIndexTo": "the token to buy" + }, + "returns": { + "dy": "the number of tokens the user will get" + } + }, + "calculateTokenAmount(SwapUtilsV2.Swap storage,uint256[],bool)": { + "details": "This shouldn't be used outside frontends for user estimates.", + "params": { + "amounts": "an array of token amounts to deposit or withdrawal, corresponding to pooledTokens. The amount should be in each pooled token's native precision. If a token charges a fee on transfers, use the amount that gets transferred after the fee.", + "deposit": "whether this is a deposit or a withdrawal", + "self": "Swap struct to read from" + }, + "returns": { + "_0": "if deposit was true, total amount of lp token that will be minted and if deposit was false, total amount of lp token that will be burned" + } + }, + "calculateWithdrawOneToken(SwapUtilsV2.Swap storage,uint256,uint8)": { + "params": { + "self": "Swap struct to read from", + "tokenAmount": "the amount to withdraw in the pool's precision", + "tokenIndex": "which token will be withdrawn" + }, + "returns": { + "_0": "the amount of token user will receive" + } + }, + "getAdminBalance(SwapUtilsV2.Swap storage,uint256)": { + "params": { + "index": "Index of the pooled token", + "self": "Swap struct to read from" + }, + "returns": { + "_0": "admin balance in the token's precision" + } + }, + "getVirtualPrice(SwapUtilsV2.Swap storage)": { + "params": { + "self": "Swap struct to read from" + }, + "returns": { + "_0": "the virtual price, scaled to precision of POOL_PRECISION_DECIMALS" + } + }, + "removeLiquidity(SwapUtilsV2.Swap storage,uint256,uint256[])": { + "details": "Liquidity can always be removed, even when the pool is paused.", + "params": { + "amount": "the amount of LP tokens to burn", + "minAmounts": "the minimum amounts of each token in the pool acceptable for this burn. Useful as a front-running mitigation", + "self": "Swap struct to read from and write to" + }, + "returns": { + "_0": "amounts of tokens the user received" + } + }, + "removeLiquidityImbalance(SwapUtilsV2.Swap storage,uint256[],uint256)": { + "params": { + "amounts": "how much of each token to withdraw", + "maxBurnAmount": "the max LP token provider is willing to pay to remove liquidity. Useful as a front-running mitigation.", + "self": "Swap struct to read from and write to" + }, + "returns": { + "_0": "actual amount of LP tokens burned in the withdrawal" + } + }, + "removeLiquidityOneToken(SwapUtilsV2.Swap storage,uint256,uint8,uint256)": { + "params": { + "minAmount": "the minimum amount to withdraw, otherwise revert", + "self": "Swap struct to read from and write to", + "tokenAmount": "the amount of the lp tokens to burn", + "tokenIndex": "the index of the token you want to receive" + }, + "returns": { + "_0": "amount chosen token that user received" + } + }, + "setAdminFee(SwapUtilsV2.Swap storage,uint256)": { + "details": "adminFee cannot be higher than 100% of the swap fee", + "params": { + "newAdminFee": "new admin fee to be applied on future transactions", + "self": "Swap struct to update" + } + }, + "setSwapFee(SwapUtilsV2.Swap storage,uint256)": { + "details": "fee cannot be higher than 1% of each swap", + "params": { + "newSwapFee": "new swap fee to be applied on future transactions", + "self": "Swap struct to update" + } + }, + "swap(SwapUtilsV2.Swap storage,uint8,uint8,uint256,uint256)": { + "params": { + "dx": "the amount of tokens the user wants to sell", + "minDy": "the min amount the user would like to receive, or revert.", + "self": "Swap struct to read from and write to", + "tokenIndexFrom": "the token the user wants to sell", + "tokenIndexTo": "the token the user wants to buy" + }, + "returns": { + "_0": "amount of token user received on swap" + } + }, + "withdrawAdminFees(SwapUtilsV2.Swap storage,address)": { + "params": { + "self": "Swap struct to withdraw fees from", + "to": "Address to send the fees to" + } + } + }, + "title": "SwapUtils library", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(SwapUtilsV2.Swap storage,uint256[],uint256)": { + "notice": "Add liquidity to the pool" + }, + "calculateRemoveLiquidity(SwapUtilsV2.Swap storage,uint256)": { + "notice": "A simple method to calculate amount of each underlying tokens that is returned upon burning given amount of LP tokens" + }, + "calculateSwap(SwapUtilsV2.Swap storage,uint8,uint8,uint256)": { + "notice": "Externally calculates a swap between two tokens." + }, + "calculateTokenAmount(SwapUtilsV2.Swap storage,uint256[],bool)": { + "notice": "A simple method to calculate prices from deposits or withdrawals, excluding fees but including slippage. This is helpful as an input into the various \"min\" parameters on calls to fight front-running" + }, + "calculateWithdrawOneToken(SwapUtilsV2.Swap storage,uint256,uint8)": { + "notice": "Calculate the dy, the amount of selected token that user receives and the fee of withdrawing in one token" + }, + "getAdminBalance(SwapUtilsV2.Swap storage,uint256)": { + "notice": "return accumulated amount of admin fees of the token with given index" + }, + "getVirtualPrice(SwapUtilsV2.Swap storage)": { + "notice": "Get the virtual price, to help calculate profit" + }, + "removeLiquidity(SwapUtilsV2.Swap storage,uint256,uint256[])": { + "notice": "Burn LP tokens to remove liquidity from the pool." + }, + "removeLiquidityImbalance(SwapUtilsV2.Swap storage,uint256[],uint256)": { + "notice": "Remove liquidity from the pool, weighted differently than the pool's current balances." + }, + "removeLiquidityOneToken(SwapUtilsV2.Swap storage,uint256,uint8,uint256)": { + "notice": "Remove liquidity from the pool all in one token." + }, + "setAdminFee(SwapUtilsV2.Swap storage,uint256)": { + "notice": "Sets the admin fee" + }, + "setSwapFee(SwapUtilsV2.Swap storage,uint256)": { + "notice": "update the swap fee" + }, + "swap(SwapUtilsV2.Swap storage,uint8,uint8,uint256,uint256)": { + "notice": "swap two tokens in the pool" + }, + "withdrawAdminFees(SwapUtilsV2.Swap storage,address)": { + "notice": "withdraw all admin fees to a given address" + } + }, + "notice": "A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} diff --git a/deployments/base_testnet/USDC.json b/deployments/base_testnet/USDC.json new file mode 100644 index 00000000..8abda9c1 --- /dev/null +++ b/deployments/base_testnet/USDC.json @@ -0,0 +1,225 @@ +{ + "abi": [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } + ], + "address": "0x05c7B9a39f150325145C410654a716DFcAA78066" +} diff --git a/deployments/base_testnet/USDT.json b/deployments/base_testnet/USDT.json new file mode 100644 index 00000000..8abda9c1 --- /dev/null +++ b/deployments/base_testnet/USDT.json @@ -0,0 +1,225 @@ +{ + "abi": [ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_spender", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_from", + "type": "address" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_to", + "type": "address" + }, + { + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_owner", + "type": "address" + }, + { + "name": "_spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } + ], + "address": "0x05c7B9a39f150325145C410654a716DFcAA78066" +} diff --git a/deployments/base_testnet/WETH.json b/deployments/base_testnet/WETH.json new file mode 100644 index 00000000..f3a4bf00 --- /dev/null +++ b/deployments/base_testnet/WETH.json @@ -0,0 +1,208 @@ +{ + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "guy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Withdrawal", + "type": "event" + }, + { "payable": true, "stateMutability": "payable", "type": "fallback" }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "guy", "type": "address" }, + { "internalType": "uint256", "name": "wad", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "deposit", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "wad", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "src", "type": "address" }, + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "wad", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "uint256", "name": "wad", "type": "uint256" } + ], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "address": "0x4200000000000000000000000000000000000006" +} diff --git a/deployments/base_testnet/solcInputs/5d7138b5466db9111ae85d9f4162357d.json b/deployments/base_testnet/solcInputs/5d7138b5466db9111ae85d9f4162357d.json new file mode 100644 index 00000000..bd2bff8f --- /dev/null +++ b/deployments/base_testnet/solcInputs/5d7138b5466db9111ae85d9f4162357d.json @@ -0,0 +1,83 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-4.7.3/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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(uint160(account), 20),\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-4.7.3/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-4.7.3/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-4.7.3/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" + }, + "@openzeppelin/contracts-4.7.3/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-4.7.3/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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" + }, + "@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/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-4.7.3/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n 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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\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-4.7.3/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)\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 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 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 return _values(set._inner);\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 on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\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" + }, + "contracts/helper/DummyERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/presets/ERC20PresetMinterPauser.sol\";\n\ncontract DummyERC20 is ERC20PresetMinterPauser {\n constructor(string memory name, string memory symbol)\n ERC20PresetMinterPauser(name, symbol)\n {}\n\n function mint(address to, uint256 amount) public virtual override {\n assert(amount <= 10000000000000000000);\n _mint(to, amount);\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 10000 + }, + "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/deployments/base_testnet/solcInputs/bc3a64a5cffb1e8de0dbf9fb306e4f9f.json b/deployments/base_testnet/solcInputs/bc3a64a5cffb1e8de0dbf9fb306e4f9f.json new file mode 100644 index 00000000..2f4dc448 --- /dev/null +++ b/deployments/base_testnet/solcInputs/bc3a64a5cffb1e8de0dbf9fb306e4f9f.json @@ -0,0 +1,317 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/Initializable.sol\";\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 initializer {\n __Context_init_unchained();\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal initializer {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathUpgradeable {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.4.24 <0.8.0;\n\nimport \"../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-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 */\nabstract contract Initializable {\n\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || _isConstructor() || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /// @dev Returns true if and only if the function is running in the constructor\n function _isConstructor() private view returns (bool) {\n return !AddressUpgradeable.isContract(address(this));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"./ERC20Upgradeable.sol\";\nimport \"../../proxy/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\n function __ERC20Burnable_init() internal initializer {\n __Context_init_unchained();\n __ERC20Burnable_init_unchained();\n }\n\n function __ERC20Burnable_init_unchained() internal initializer {\n }\n using SafeMathUpgradeable for uint256;\n\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \"ERC20: burn amount exceeds allowance\");\n\n _approve(account, _msgSender(), decreasedAllowance);\n _burn(account, amount);\n }\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"./IERC20Upgradeable.sol\";\nimport \"../../math/SafeMathUpgradeable.sol\";\nimport \"../../proxy/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {\n using SafeMathUpgradeable for uint256;\n\n mapping (address => uint256) private _balances;\n\n mapping (address => mapping (address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n /**\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n * a default value of 18.\n *\n * To select a different value for {decimals}, use {_setupDecimals}.\n *\n * All three of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal initializer {\n __Context_init_unchained();\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {\n _name = name_;\n _symbol = symbol_;\n _decimals = 18;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n * called.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return _decimals;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n return true;\n }\n\n /**\n * @dev Moves tokens `amount` from `sender` to `recipient`.\n *\n * This is internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n _balances[recipient] = _balances[recipient].add(amount);\n emit Transfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply = _totalSupply.add(amount);\n _balances[account] = _balances[account].add(amount);\n emit Transfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n _totalSupply = _totalSupply.sub(amount);\n emit Transfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Sets {decimals} to a value other than the default one of 18.\n *\n * WARNING: This function should only be called from the constructor. Most\n * applications that interact with token contracts will not expect\n * {decimals} to ever change, and may work incorrectly if it does.\n */\n function _setupDecimals(uint8 decimals_) internal virtual {\n _decimals = decimals_;\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be to transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\n uint256[44] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary 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 function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/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 GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal initializer {\n __Context_init_unchained();\n }\n\n function __Context_init_unchained() internal initializer {\n }\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./ContextUpgradeable.sol\";\nimport \"../proxy/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 initializer {\n __Context_init_unchained();\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal initializer {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal initializer {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal initializer {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/EnumerableSet.sol\";\nimport \"../utils/Address.sol\";\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context {\n using EnumerableSet for EnumerableSet.AddressSet;\n using Address for address;\n\n struct RoleData {\n EnumerableSet.AddressSet members;\n bytes32 adminRole;\n }\n\n mapping (bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view returns (bool) {\n return _roles[role].members.contains(account);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view returns (uint256) {\n return _roles[role].members.length();\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view returns (address) {\n return _roles[role].members.at(index);\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to grant\");\n\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual {\n require(hasRole(_roles[role].adminRole, _msgSender()), \"AccessControl: sender must be an admin to revoke\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);\n _roles[role].adminRole = adminRole;\n }\n\n function _grantRole(bytes32 role, address account) private {\n if (_roles[role].members.add(account)) {\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n function _revokeRole(bytes32 role, address account) private {\n if (_roles[role].members.remove(account)) {\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/Context.sol\";\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 () internal {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = 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 emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" + }, + "@openzeppelin/contracts/cryptography/MerkleProof.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev These functions deal with verification of Merkle trees (hash trees),\n */\nlibrary MerkleProof {\n /**\n * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree\n * defined by `root`. For this, a `proof` must be provided, containing\n * sibling hashes on the branch from the leaf to the root of the tree. Each\n * pair of leaves and each pair of pre-images are assumed to be sorted.\n */\n function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {\n bytes32 computedHash = leaf;\n\n for (uint256 i = 0; i < proof.length; i++) {\n bytes32 proofElement = proof[i];\n\n if (computedHash <= proofElement) {\n // Hash(current computed hash + current element of the proof)\n computedHash = keccak256(abi.encodePacked(computedHash, proofElement));\n } else {\n // Hash(current element of the proof + current computed hash)\n computedHash = keccak256(abi.encodePacked(proofElement, computedHash));\n }\n }\n\n // Check if the computed hash (root) is equal to the provided root\n return computedHash == root;\n }\n}\n" + }, + "@openzeppelin/contracts/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165 is IERC165 {\n /*\n * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7\n */\n bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\n\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n constructor () internal {\n // Derived contracts need only register support for their own interfaces,\n // we register support for ERC165 itself here\n _registerInterface(_INTERFACE_ID_ERC165);\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n *\n * Time complexity O(1), guaranteed to always use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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/math/SafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Clones.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\n *\n * This function uses the create opcode, which should never revert.\n */\n function clone(address master) internal returns (address instance) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create(0, ptr, 0x37)\n }\n require(instance != address(0), \"ERC1167: create failed\");\n }\n\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.\n *\n * This function uses the create2 opcode and a `salt` to deterministically deploy\n * the clone. Using the same `master` and `salt` multiple time will revert, since\n * the clones cannot be deployed twice at the same address.\n */\n function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create2(0, ptr, 0x37, salt)\n }\n require(instance != address(0), \"ERC1167: create2 failed\");\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, master))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\n mstore(add(ptr, 0x38), shl(0x60, deployer))\n mstore(add(ptr, 0x4c), salt)\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\n predicted := keccak256(add(ptr, 0x37), 0x55)\n }\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {\n return predictDeterministicAddress(master, salt, address(this));\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20 {\n using SafeMath for uint256;\n\n mapping (address => uint256) private _balances;\n\n mapping (address => mapping (address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n /**\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n * a default value of 18.\n *\n * To select a different value for {decimals}, use {_setupDecimals}.\n *\n * All three of these values are immutable: they can only be set once during\n * construction.\n */\n constructor (string memory name_, string memory symbol_) public {\n _name = name_;\n _symbol = symbol_;\n _decimals = 18;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n * called.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return _decimals;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n return true;\n }\n\n /**\n * @dev Moves tokens `amount` from `sender` to `recipient`.\n *\n * This is internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n _balances[recipient] = _balances[recipient].add(amount);\n emit Transfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply = _totalSupply.add(amount);\n _balances[account] = _balances[account].add(amount);\n emit Transfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n _totalSupply = _totalSupply.sub(amount);\n emit Transfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Sets {decimals} to a value other than the default one of 18.\n *\n * WARNING: This function should only be called from the constructor. Most\n * applications that interact with token contracts will not expect\n * {decimals} to ever change, and may work incorrectly if it does.\n */\n function _setupDecimals(uint8 decimals_) internal virtual {\n _decimals = decimals_;\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be to transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./ERC20.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n using SafeMath for uint256;\n\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, \"ERC20: burn amount exceeds allowance\");\n\n _approve(account, _msgSender(), decreasedAllowance);\n _burn(account, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.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 SafeMath for uint256;\n using Address for address;\n\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) 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(IERC20 token, address spender, uint256 value) 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 // solhint-disable-next-line max-line-length\n require((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(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).add(value);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 newAllowance = token.allowance(address(this), spender).sub(value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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) { // Return data is optional\n // solhint-disable-next-line max-line-length\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./IERC721.sol\";\nimport \"./IERC721Metadata.sol\";\nimport \"./IERC721Enumerable.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"../../introspection/ERC165.sol\";\nimport \"../../math/SafeMath.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/EnumerableSet.sol\";\nimport \"../../utils/EnumerableMap.sol\";\nimport \"../../utils/Strings.sol\";\n\n/**\n * @title ERC721 Non-Fungible Token Standard basic implementation\n * @dev see https://eips.ethereum.org/EIPS/eip-721\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {\n using SafeMath for uint256;\n using Address for address;\n using EnumerableSet for EnumerableSet.UintSet;\n using EnumerableMap for EnumerableMap.UintToAddressMap;\n using Strings for uint256;\n\n // Equals to `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`\n bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;\n\n // Mapping from holder address to their (enumerable) set of owned tokens\n mapping (address => EnumerableSet.UintSet) private _holderTokens;\n\n // Enumerable mapping from token ids to their owners\n EnumerableMap.UintToAddressMap private _tokenOwners;\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 // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Optional mapping for token URIs\n mapping (uint256 => string) private _tokenURIs;\n\n // Base URI\n string private _baseURI;\n\n /*\n * bytes4(keccak256('balanceOf(address)')) == 0x70a08231\n * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e\n * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3\n * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc\n * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465\n * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5\n * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd\n * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e\n * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde\n *\n * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^\n * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd\n */\n bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;\n\n /*\n * bytes4(keccak256('name()')) == 0x06fdde03\n * bytes4(keccak256('symbol()')) == 0x95d89b41\n * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd\n *\n * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f\n */\n bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;\n\n /*\n * bytes4(keccak256('totalSupply()')) == 0x18160ddd\n * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59\n * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7\n *\n * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63\n */\n bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor (string memory name_, string memory symbol_) public {\n _name = name_;\n _symbol = symbol_;\n\n // register the supported interfaces to conform to ERC721 via ERC165\n _registerInterface(_INTERFACE_ID_ERC721);\n _registerInterface(_INTERFACE_ID_ERC721_METADATA);\n _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);\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: balance query for the zero address\");\n return _holderTokens[owner].length();\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n return _tokenOwners.get(tokenId, \"ERC721: owner query for nonexistent token\");\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 require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.\n return string(abi.encodePacked(base, tokenId.toString()));\n }\n\n /**\n * @dev Returns the base URI set via {_setBaseURI}. This will be\n * automatically added as a prefix in {tokenURI} to each token's URI, or\n * to the token ID if no specific URI is set for that token ID.\n */\n function baseURI() public view virtual returns (string memory) {\n return _baseURI;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n return _holderTokens[owner].at(index);\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds\n return _tokenOwners.length();\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n (uint256 tokenId, ) = _tokenOwners.at(index);\n return tokenId;\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not owner nor 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 require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\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 require(operator != _msgSender(), \"ERC721: approve to caller\");\n\n _operatorApprovals[_msgSender()][operator] = approved;\n emit ApprovalForAll(_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(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor 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(address from, address to, uint256 tokenId, bytes memory _data) 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 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 _tokenOwners.contains(tokenId);\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 require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n d*\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(address to, uint256 tokenId, bytes memory _data) internal virtual {\n _mint(to, tokenId);\n require(_checkOnERC721Received(address(0), to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\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);\n\n _holderTokens[to].add(tokenId);\n\n _tokenOwners.set(tokenId, to);\n\n emit Transfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\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 = ERC721.ownerOf(tokenId); // internal owner\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n // Clear metadata (if any)\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n delete _tokenURIs[tokenId];\n }\n\n _holderTokens[owner].remove(tokenId);\n\n _tokenOwners.remove(tokenId);\n\n emit Transfer(owner, address(0), tokenId);\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(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer of token that is not own\"); // internal owner\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _holderTokens[from].remove(tokenId);\n _holderTokens[to].add(tokenId);\n\n _tokenOwners.set(tokenId, to);\n\n emit Transfer(from, to, tokenId);\n }\n\n /**\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\n require(_exists(tokenId), \"ERC721Metadata: URI set of nonexistent token\");\n _tokenURIs[tokenId] = _tokenURI;\n }\n\n /**\n * @dev Internal function to set the base URI for all token IDs. It is\n * automatically added as a prefix to the value returned in {tokenURI},\n * or to the token ID if {tokenURI} is empty.\n */\n function _setBaseURI(string memory baseURI_) internal virtual {\n _baseURI = baseURI_;\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(address from, address to, uint256 tokenId, bytes memory _data)\n private returns (bool)\n {\n if (!to.isContract()) {\n return true;\n }\n bytes memory returndata = to.functionCall(abi.encodeWithSelector(\n IERC721Receiver(to).onERC721Received.selector,\n _msgSender(),\n from,\n tokenId,\n _data\n ), \"ERC721: transfer to non ERC721Receiver implementer\");\n bytes4 retval = abi.decode(returndata, (bytes4));\n return (retval == _ERC721_RECEIVED);\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(ERC721.ownerOf(tokenId), to, tokenId); // internal owner\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"../../introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"./IERC721.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 IERC721Metadata is IERC721 {\n\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/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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 IERC721Receiver {\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 `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/EnumerableMap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Library for managing an enumerable variant of Solidity's\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\n * type.\n *\n * Maps have the following properties:\n *\n * - Entries are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\n *\n * // Declare a set state variable\n * EnumerableMap.UintToAddressMap private myMap;\n * }\n * ```\n *\n * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are\n * supported.\n */\nlibrary EnumerableMap {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Map type with\n // bytes32 keys and values.\n // The Map implementation uses private functions, and user-facing\n // implementations (such as Uint256ToAddressMap) are just wrappers around\n // the underlying Map.\n // This means that we can only create new EnumerableMaps for types that fit\n // in bytes32.\n\n struct MapEntry {\n bytes32 _key;\n bytes32 _value;\n }\n\n struct Map {\n // Storage of map keys and values\n MapEntry[] _entries;\n\n // Position of the entry defined by a key in the `entries` array, plus 1\n // because index 0 means a key is not in the map.\n mapping (bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {\n // We read and store the key's index to prevent multiple reads from the same storage slot\n uint256 keyIndex = map._indexes[key];\n\n if (keyIndex == 0) { // Equivalent to !contains(map, key)\n map._entries.push(MapEntry({ _key: key, _value: value }));\n // The entry is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n map._indexes[key] = map._entries.length;\n return true;\n } else {\n map._entries[keyIndex - 1]._value = value;\n return false;\n }\n }\n\n /**\n * @dev Removes a key-value pair from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function _remove(Map storage map, bytes32 key) private returns (bool) {\n // We read and store the key's index to prevent multiple reads from the same storage slot\n uint256 keyIndex = map._indexes[key];\n\n if (keyIndex != 0) { // Equivalent to contains(map, key)\n // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one\n // in the array, and then remove the last entry (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = keyIndex - 1;\n uint256 lastIndex = map._entries.length - 1;\n\n // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n MapEntry storage lastEntry = map._entries[lastIndex];\n\n // Move the last entry to the index where the entry to delete is\n map._entries[toDeleteIndex] = lastEntry;\n // Update the index for the moved entry\n map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved entry was stored\n map._entries.pop();\n\n // Delete the index for the deleted slot\n delete map._indexes[key];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\n return map._indexes[key] != 0;\n }\n\n /**\n * @dev Returns the number of key-value pairs in the map. O(1).\n */\n function _length(Map storage map) private view returns (uint256) {\n return map._entries.length;\n }\n\n /**\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\n *\n * Note that there are no guarantees on the ordering of entries inside the\n * array, and it may change when more entries are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\n require(map._entries.length > index, \"EnumerableMap: index out of bounds\");\n\n MapEntry storage entry = map._entries[index];\n return (entry._key, entry._value);\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {\n uint256 keyIndex = map._indexes[key];\n if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)\n return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\n uint256 keyIndex = map._indexes[key];\n require(keyIndex != 0, \"EnumerableMap: nonexistent key\"); // Equivalent to contains(map, key)\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\n }\n\n /**\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {_tryGet}.\n */\n function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {\n uint256 keyIndex = map._indexes[key];\n require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\n }\n\n // UintToAddressMap\n\n struct UintToAddressMap {\n Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\n return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\n return _remove(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\n return _contains(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(UintToAddressMap storage map) internal view returns (uint256) {\n return _length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the set. O(1).\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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\n (bytes32 key, bytes32 value) = _at(map._inner, index);\n return (uint256(key), address(uint160(uint256(value))));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n *\n * _Available since v3.4._\n */\n function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\n (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));\n return (success, address(uint160(uint256(value))));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\n return address(uint160(uint256(_get(map._inner, bytes32(key)))));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {\n return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length > index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor () internal {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "@openzeppelin/contracts/utils/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor () internal {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n uint256 index = digits - 1;\n temp = value;\n while (temp != 0) {\n buffer[index--] = bytes1(uint8(48 + temp % 10));\n temp /= 10;\n }\n return string(buffer);\n }\n}\n" + }, + "contracts/AmplificationUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"./SwapUtils.sol\";\n\n/**\n * @title AmplificationUtils library\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtils.Swap` struct.\n * This library assumes the struct is fully validated.\n */\nlibrary AmplificationUtils {\n using SafeMath for uint256;\n\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n // Constant values used in ramping A calculations\n uint256 public constant A_PRECISION = 100;\n uint256 public constant MAX_A = 10**6;\n uint256 private constant MAX_A_CHANGE = 2;\n uint256 private constant MIN_RAMP_TIME = 14 days;\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter\n */\n function getA(SwapUtils.Swap storage self) external view returns (uint256) {\n return _getAPrecise(self).div(A_PRECISION);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function getAPrecise(SwapUtils.Swap storage self)\n external\n view\n returns (uint256)\n {\n return _getAPrecise(self);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function _getAPrecise(SwapUtils.Swap storage self)\n internal\n view\n returns (uint256)\n {\n uint256 t1 = self.futureATime; // time when ramp is finished\n uint256 a1 = self.futureA; // final A value when ramp is finished\n\n if (block.timestamp < t1) {\n uint256 t0 = self.initialATime; // time when ramp is started\n uint256 a0 = self.initialA; // initial A value when ramp is started\n if (a1 > a0) {\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.add(\n a1.sub(a0).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n } else {\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.sub(\n a0.sub(a1).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n }\n } else {\n return a1;\n }\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param self Swap struct to update\n * @param futureA_ the new A to ramp towards\n * @param futureTime_ timestamp when the new A should be reached\n */\n function rampA(\n SwapUtils.Swap storage self,\n uint256 futureA_,\n uint256 futureTime_\n ) external {\n require(\n block.timestamp >= self.initialATime.add(1 days),\n \"Wait 1 day before starting ramp\"\n );\n require(\n futureTime_ >= block.timestamp.add(MIN_RAMP_TIME),\n \"Insufficient ramp time\"\n );\n require(\n futureA_ > 0 && futureA_ < MAX_A,\n \"futureA_ must be > 0 and < MAX_A\"\n );\n\n uint256 initialAPrecise = _getAPrecise(self);\n uint256 futureAPrecise = futureA_.mul(A_PRECISION);\n\n if (futureAPrecise < initialAPrecise) {\n require(\n futureAPrecise.mul(MAX_A_CHANGE) >= initialAPrecise,\n \"futureA_ is too small\"\n );\n } else {\n require(\n futureAPrecise <= initialAPrecise.mul(MAX_A_CHANGE),\n \"futureA_ is too large\"\n );\n }\n\n self.initialA = initialAPrecise;\n self.futureA = futureAPrecise;\n self.initialATime = block.timestamp;\n self.futureATime = futureTime_;\n\n emit RampA(\n initialAPrecise,\n futureAPrecise,\n block.timestamp,\n futureTime_\n );\n }\n\n /**\n * @notice Stops ramping A immediately. Once this function is called, rampA()\n * cannot be called for another 24 hours\n * @param self Swap struct to update\n */\n function stopRampA(SwapUtils.Swap storage self) external {\n require(self.futureATime > block.timestamp, \"Ramp is already stopped\");\n\n uint256 currentA = _getAPrecise(self);\n self.initialA = currentA;\n self.futureA = currentA;\n self.initialATime = block.timestamp;\n self.futureATime = block.timestamp;\n\n emit StopRampA(currentA, block.timestamp);\n }\n}\n" + }, + "contracts/AmplificationUtilsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"./SwapUtilsV1.sol\";\n\n/**\n * @title AmplificationUtils library\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtils.Swap` struct.\n * This library assumes the struct is fully validated.\n */\nlibrary AmplificationUtilsV1 {\n using SafeMath for uint256;\n\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n // Constant values used in ramping A calculations\n uint256 public constant A_PRECISION = 100;\n uint256 public constant MAX_A = 10**6;\n uint256 private constant MAX_A_CHANGE = 2;\n uint256 private constant MIN_RAMP_TIME = 14 days;\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter\n */\n function getA(SwapUtilsV1.Swap storage self)\n external\n view\n returns (uint256)\n {\n return _getAPrecise(self).div(A_PRECISION);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function getAPrecise(SwapUtilsV1.Swap storage self)\n external\n view\n returns (uint256)\n {\n return _getAPrecise(self);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function _getAPrecise(SwapUtilsV1.Swap storage self)\n internal\n view\n returns (uint256)\n {\n uint256 t1 = self.futureATime; // time when ramp is finished\n uint256 a1 = self.futureA; // final A value when ramp is finished\n\n if (block.timestamp < t1) {\n uint256 t0 = self.initialATime; // time when ramp is started\n uint256 a0 = self.initialA; // initial A value when ramp is started\n if (a1 > a0) {\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.add(\n a1.sub(a0).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n } else {\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.sub(\n a0.sub(a1).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n }\n } else {\n return a1;\n }\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param self Swap struct to update\n * @param futureA_ the new A to ramp towards\n * @param futureTime_ timestamp when the new A should be reached\n */\n function rampA(\n SwapUtilsV1.Swap storage self,\n uint256 futureA_,\n uint256 futureTime_\n ) external {\n require(\n block.timestamp >= self.initialATime.add(1 days),\n \"Wait 1 day before starting ramp\"\n );\n require(\n futureTime_ >= block.timestamp.add(MIN_RAMP_TIME),\n \"Insufficient ramp time\"\n );\n require(\n futureA_ > 0 && futureA_ < MAX_A,\n \"futureA_ must be > 0 and < MAX_A\"\n );\n\n uint256 initialAPrecise = _getAPrecise(self);\n uint256 futureAPrecise = futureA_.mul(A_PRECISION);\n\n if (futureAPrecise < initialAPrecise) {\n require(\n futureAPrecise.mul(MAX_A_CHANGE) >= initialAPrecise,\n \"futureA_ is too small\"\n );\n } else {\n require(\n futureAPrecise <= initialAPrecise.mul(MAX_A_CHANGE),\n \"futureA_ is too large\"\n );\n }\n\n self.initialA = initialAPrecise;\n self.futureA = futureAPrecise;\n self.initialATime = block.timestamp;\n self.futureATime = futureTime_;\n\n emit RampA(\n initialAPrecise,\n futureAPrecise,\n block.timestamp,\n futureTime_\n );\n }\n\n /**\n * @notice Stops ramping A immediately. Once this function is called, rampA()\n * cannot be called for another 24 hours\n * @param self Swap struct to update\n */\n function stopRampA(SwapUtilsV1.Swap storage self) external {\n require(self.futureATime > block.timestamp, \"Ramp is already stopped\");\n\n uint256 currentA = _getAPrecise(self);\n self.initialA = currentA;\n self.futureA = currentA;\n self.initialATime = block.timestamp;\n self.futureATime = block.timestamp;\n\n emit StopRampA(currentA, block.timestamp);\n }\n}\n" + }, + "contracts/GeneralizedSwapMigrator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./interfaces/ISwap.sol\";\nimport \"./helper/BaseBoringBatchable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title GeneralizedSwapMigrator\n * @notice This contract is responsible for migration liquidity between pools\n * Users can use this contract to remove their liquidity from the old pools and add them to the new\n * ones with a single transaction.\n */\ncontract GeneralizedSwapMigrator is Ownable, BaseBoringBatchable {\n using SafeERC20 for IERC20;\n\n struct MigrationData {\n address newPoolAddress;\n IERC20 oldPoolLPTokenAddress;\n IERC20 newPoolLPTokenAddress;\n IERC20[] tokens;\n }\n\n uint256 private constant MAX_UINT256 = 2**256 - 1;\n mapping(address => MigrationData) public migrationMap;\n\n event AddMigrationData(address indexed oldPoolAddress, MigrationData mData);\n event Migrate(\n address indexed migrator,\n address indexed oldPoolAddress,\n uint256 oldLPTokenAmount,\n uint256 newLPTokenAmount\n );\n\n constructor() public Ownable() {}\n\n /**\n * @notice Add new migration data to the contract\n * @param oldPoolAddress pool address to migrate from\n * @param mData MigrationData struct that contains information of the old and new pools\n * @param overwrite should overwrite existing migration data\n */\n function addMigrationData(\n address oldPoolAddress,\n MigrationData memory mData,\n bool overwrite\n ) external onlyOwner {\n // Check\n if (!overwrite) {\n require(\n address(migrationMap[oldPoolAddress].oldPoolLPTokenAddress) ==\n address(0),\n \"cannot overwrite existing migration data\"\n );\n }\n require(\n address(mData.oldPoolLPTokenAddress) != address(0),\n \"oldPoolLPTokenAddress == 0\"\n );\n require(\n address(mData.newPoolLPTokenAddress) != address(0),\n \"newPoolLPTokenAddress == 0\"\n );\n\n for (uint8 i = 0; i < 32; i++) {\n address oldPoolToken;\n try ISwap(oldPoolAddress).getToken(i) returns (IERC20 token) {\n oldPoolToken = address(token);\n } catch {\n require(i > 0, \"Failed to get tokens underlying Saddle pool.\");\n oldPoolToken = address(0);\n }\n\n try ISwap(mData.newPoolAddress).getToken(i) returns (IERC20 token) {\n require(\n oldPoolToken == address(token) &&\n oldPoolToken == address(mData.tokens[i]),\n \"Failed to match tokens list\"\n );\n } catch {\n require(i > 0, \"Failed to get tokens underlying Saddle pool.\");\n require(\n oldPoolToken == address(0) && i == mData.tokens.length,\n \"Failed to match tokens list\"\n );\n break;\n }\n }\n\n // Effect\n migrationMap[oldPoolAddress] = mData;\n\n // Interaction\n // Approve old LP Token to be used for withdraws.\n mData.oldPoolLPTokenAddress.approve(oldPoolAddress, MAX_UINT256);\n\n // Approve underlying tokens to be used for deposits.\n for (uint256 i = 0; i < mData.tokens.length; i++) {\n mData.tokens[i].safeApprove(mData.newPoolAddress, 0);\n mData.tokens[i].safeApprove(mData.newPoolAddress, MAX_UINT256);\n }\n\n emit AddMigrationData(oldPoolAddress, mData);\n }\n\n /**\n * @notice Migrates saddle LP tokens from a pool to another\n * @param oldPoolAddress pool address to migrate from\n * @param amount amount of LP tokens to migrate\n * @param minAmount of new LP tokens to receive\n */\n function migrate(\n address oldPoolAddress,\n uint256 amount,\n uint256 minAmount\n ) external returns (uint256) {\n // Check\n MigrationData memory mData = migrationMap[oldPoolAddress];\n require(\n address(mData.oldPoolLPTokenAddress) != address(0),\n \"migration is not available\"\n );\n\n // Interactions\n // Transfer old LP token from the caller\n mData.oldPoolLPTokenAddress.safeTransferFrom(\n msg.sender,\n address(this),\n amount\n );\n\n // Remove liquidity from the old pool\n uint256[] memory amounts = ISwap(oldPoolAddress).removeLiquidity(\n amount,\n new uint256[](mData.tokens.length),\n MAX_UINT256\n );\n // Add acquired liquidity to the new pool\n uint256 mintedAmount = ISwap(mData.newPoolAddress).addLiquidity(\n amounts,\n minAmount,\n MAX_UINT256\n );\n\n // Transfer new LP Token to the caller\n mData.newPoolLPTokenAddress.safeTransfer(msg.sender, mintedAmount);\n\n emit Migrate(msg.sender, oldPoolAddress, amount, mintedAmount);\n return mintedAmount;\n }\n\n /**\n * @notice Rescues any token that may be sent to this contract accidentally.\n * @param token Amount of old LPToken to migrate\n * @param to Minimum amount of new LPToken to receive\n */\n function rescue(IERC20 token, address to) external onlyOwner {\n token.safeTransfer(to, token.balanceOf(address(this)));\n }\n}\n" + }, + "contracts/guarded/Allowlist.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/cryptography/MerkleProof.sol\";\nimport \"../interfaces/IAllowlist.sol\";\n\n/**\n * @title Allowlist\n * @notice This contract is a registry holding information about how much each swap contract should\n * contain upto. Swap.sol will rely on this contract to determine whether the pool cap is reached and\n * also whether a user's deposit limit is reached.\n */\ncontract Allowlist is Ownable, IAllowlist {\n using SafeMath for uint256;\n\n // Represents the root node of merkle tree containing a list of eligible addresses\n bytes32 public merkleRoot;\n // Maps pool address -> maximum total supply\n mapping(address => uint256) private poolCaps;\n // Maps pool address -> maximum amount of pool token mintable per account\n mapping(address => uint256) private accountLimits;\n // Maps account address -> boolean value indicating whether it has been checked and verified against the merkle tree\n mapping(address => bool) private verified;\n\n event PoolCap(address indexed poolAddress, uint256 poolCap);\n event PoolAccountLimit(address indexed poolAddress, uint256 accountLimit);\n event NewMerkleRoot(bytes32 merkleRoot);\n\n /**\n * @notice Creates this contract and sets the PoolCap of 0x0 with uint256(0x54dd1e) for\n * crude checking whether an address holds this contract.\n * @param merkleRoot_ bytes32 that represent a merkle root node. This is generated off chain with the list of\n * qualifying addresses.\n */\n constructor(bytes32 merkleRoot_) public {\n merkleRoot = merkleRoot_;\n\n // This value will be used as a way of crude checking whether an address holds this Allowlist contract\n // Value 0x54dd1e has no inherent meaning other than it is arbitrary value that checks for\n // user error.\n poolCaps[address(0x0)] = uint256(0x54dd1e);\n emit PoolCap(address(0x0), uint256(0x54dd1e));\n emit NewMerkleRoot(merkleRoot_);\n }\n\n /**\n * @notice Returns the max mintable amount of the lp token per account in given pool address.\n * @param poolAddress address of the pool\n * @return max mintable amount of the lp token per account\n */\n function getPoolAccountLimit(address poolAddress)\n external\n view\n override\n returns (uint256)\n {\n return accountLimits[poolAddress];\n }\n\n /**\n * @notice Returns the maximum total supply of the pool token for the given pool address.\n * @param poolAddress address of the pool\n */\n function getPoolCap(address poolAddress)\n external\n view\n override\n returns (uint256)\n {\n return poolCaps[poolAddress];\n }\n\n /**\n * @notice Returns true if the given account's existence has been verified against any of the past or\n * the present merkle tree. Note that if it has been verified in the past, this function will return true\n * even if the current merkle tree does not contain the account.\n * @param account the address to check if it has been verified\n * @return a boolean value representing whether the account has been verified in the past or the present merkle tree\n */\n function isAccountVerified(address account) external view returns (bool) {\n return verified[account];\n }\n\n /**\n * @notice Checks the existence of keccak256(account) as a node in the merkle tree inferred by the merkle root node\n * stored in this contract. Pools should use this function to check if the given address qualifies for depositing.\n * If the given account has already been verified with the correct merkleProof, this function will return true when\n * merkleProof is empty. The verified status will be overwritten if the previously verified user calls this function\n * with an incorrect merkleProof.\n * @param account address to confirm its existence in the merkle tree\n * @param merkleProof data that is used to prove the existence of given parameters. This is generated\n * during the creation of the merkle tree. Users should retrieve this data off-chain.\n * @return a boolean value that corresponds to whether the address with the proof has been verified in the past\n * or if they exist in the current merkle tree.\n */\n function verifyAddress(address account, bytes32[] calldata merkleProof)\n external\n override\n returns (bool)\n {\n if (merkleProof.length != 0) {\n // Verify the account exists in the merkle tree via the MerkleProof library\n bytes32 node = keccak256(abi.encodePacked(account));\n if (MerkleProof.verify(merkleProof, merkleRoot, node)) {\n verified[account] = true;\n return true;\n }\n }\n return verified[account];\n }\n\n // ADMIN FUNCTIONS\n\n /**\n * @notice Sets the account limit of allowed deposit amounts for the given pool\n * @param poolAddress address of the pool\n * @param accountLimit the max number of the pool token a single user can mint\n */\n function setPoolAccountLimit(address poolAddress, uint256 accountLimit)\n external\n onlyOwner\n {\n require(poolAddress != address(0x0), \"0x0 is not a pool address\");\n accountLimits[poolAddress] = accountLimit;\n emit PoolAccountLimit(poolAddress, accountLimit);\n }\n\n /**\n * @notice Sets the max total supply of LPToken for the given pool address\n * @param poolAddress address of the pool\n * @param poolCap the max total supply of the pool token\n */\n function setPoolCap(address poolAddress, uint256 poolCap)\n external\n onlyOwner\n {\n require(poolAddress != address(0x0), \"0x0 is not a pool address\");\n poolCaps[poolAddress] = poolCap;\n emit PoolCap(poolAddress, poolCap);\n }\n\n /**\n * @notice Updates the merkle root that is stored in this contract. This can only be called by\n * the owner. If more addresses are added to the list, a new merkle tree and a merkle root node should be generated,\n * and merkleRoot should be updated accordingly.\n * @param merkleRoot_ a new merkle root node that contains a list of deposit allowed addresses\n */\n function updateMerkleRoot(bytes32 merkleRoot_) external onlyOwner {\n merkleRoot = merkleRoot_;\n emit NewMerkleRoot(merkleRoot_);\n }\n}\n" + }, + "contracts/guarded/LPTokenGuarded.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// https://etherscan.io/address/0xC28DF698475dEC994BE00C9C9D8658A548e6304F#code\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"../interfaces/ISwapGuarded.sol\";\n\n/**\n * @title Liquidity Provider Token\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\n * It is used to represent user's shares when providing liquidity to swap contracts.\n */\ncontract LPTokenGuarded is ERC20Burnable, Ownable {\n using SafeMath for uint256;\n\n // Address of the swap contract that owns this LP token. When a user adds liquidity to the swap contract,\n // they receive a proportionate amount of this LPToken.\n ISwapGuarded public swap;\n\n // Maps user account to total number of LPToken minted by them. Used to limit minting during guarded release phase\n mapping(address => uint256) public mintedAmounts;\n\n /**\n * @notice Deploys LPToken contract with given name, symbol, and decimals\n * @dev the caller of this constructor will become the owner of this contract\n * @param name_ name of this token\n * @param symbol_ symbol of this token\n * @param decimals_ number of decimals this token will be based on\n */\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public ERC20(name_, symbol_) {\n _setupDecimals(decimals_);\n swap = ISwapGuarded(_msgSender());\n }\n\n /**\n * @notice Mints the given amount of LPToken to the recipient. During the guarded release phase, the total supply\n * and the maximum number of the tokens that a single account can mint are limited.\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n * @param merkleProof the bytes32 array data that is used to prove recipient's address exists in the merkle tree\n * stored in the allowlist contract. If the pool is not guarded, this parameter is ignored.\n */\n function mint(\n address recipient,\n uint256 amount,\n bytes32[] calldata merkleProof\n ) external onlyOwner {\n require(amount != 0, \"amount == 0\");\n\n // If the pool is in the guarded launch phase, the following checks are done to restrict deposits.\n // 1. Check if the given merkleProof corresponds to the recipient's address in the merkle tree stored in the\n // allowlist contract. If the account has been already verified, merkleProof is ignored.\n // 2. Limit the total number of this LPToken minted to recipient as defined by the allowlist contract.\n // 3. Limit the total supply of this LPToken as defined by the allowlist contract.\n if (swap.isGuarded()) {\n IAllowlist allowlist = swap.getAllowlist();\n require(\n allowlist.verifyAddress(recipient, merkleProof),\n \"Invalid merkle proof\"\n );\n uint256 totalMinted = mintedAmounts[recipient].add(amount);\n require(\n totalMinted <= allowlist.getPoolAccountLimit(address(swap)),\n \"account deposit limit\"\n );\n require(\n totalSupply().add(amount) <=\n allowlist.getPoolCap(address(swap)),\n \"pool total supply limit\"\n );\n mintedAmounts[recipient] = totalMinted;\n }\n _mint(recipient, amount);\n }\n\n /**\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\n * minting and burning. This ensures that swap.updateUserWithdrawFees are called everytime.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override(ERC20) {\n super._beforeTokenTransfer(from, to, amount);\n swap.updateUserWithdrawFee(to, amount);\n }\n}\n" + }, + "contracts/guarded/OwnerPausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/Pausable.sol\";\n\n/**\n * @title OwnerPausable\n * @notice An ownable contract allows the owner to pause and unpause the\n * contract without a delay.\n * @dev Only methods using the provided modifiers will be paused.\n */\ncontract OwnerPausable is Ownable, Pausable {\n /**\n * @notice Pause the contract. Revert if already paused.\n */\n function pause() external onlyOwner {\n Pausable._pause();\n }\n\n /**\n * @notice Unpause the contract. Revert if already unpaused.\n */\n function unpause() external onlyOwner {\n Pausable._unpause();\n }\n}\n" + }, + "contracts/guarded/SwapGuarded.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"./OwnerPausable.sol\";\nimport \"./SwapUtilsGuarded.sol\";\nimport \"../MathUtils.sol\";\nimport \"./Allowlist.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract SwapGuarded is OwnerPausable, ReentrancyGuard {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using MathUtils for uint256;\n using SwapUtilsGuarded for SwapUtilsGuarded.Swap;\n\n // Struct storing data responsible for automatic market maker functionalities. In order to\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtilsGuarded.sol\n SwapUtilsGuarded.Swap public swapStorage;\n\n // Address to allowlist contract that holds information about maximum totaly supply of lp tokens\n // and maximum mintable amount per user address. As this is immutable, this will become a constant\n // after initialization.\n IAllowlist private immutable allowlist;\n\n // Boolean value that notates whether this pool is guarded or not. When isGuarded is true,\n // addLiquidity function will be restricted by limits defined in allowlist contract.\n bool private guarded = true;\n\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\n // getTokenIndex function also relies on this mapping to retrieve token index.\n mapping(address => uint8) private tokenIndexes;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n /**\n * @notice Deploys this Swap contract with given parameters as default\n * values. This will also deploy a LPToken that represents users\n * LP position. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint new tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param _withdrawFee default withdrawFee to be initialized with\n * @param _allowlist address of allowlist contract for guarded launch\n */\n constructor(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n uint256 _withdrawFee,\n IAllowlist _allowlist\n ) public OwnerPausable() ReentrancyGuard() {\n // Check _pooledTokens and precisions parameter\n require(_pooledTokens.length > 1, \"_pooledTokens.length <= 1\");\n require(_pooledTokens.length <= 32, \"_pooledTokens.length > 32\");\n require(\n _pooledTokens.length == decimals.length,\n \"_pooledTokens decimals mismatch\"\n );\n\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\n\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\n if (i > 0) {\n // Check if index is already used. Check if 0th element is a duplicate.\n require(\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\n _pooledTokens[0] != _pooledTokens[i],\n \"Duplicate tokens\"\n );\n }\n require(\n address(_pooledTokens[i]) != address(0),\n \"The 0 address isn't an ERC-20\"\n );\n require(\n decimals[i] <= SwapUtilsGuarded.POOL_PRECISION_DECIMALS,\n \"Token decimals exceeds max\"\n );\n precisionMultipliers[i] =\n 10 **\n uint256(SwapUtilsGuarded.POOL_PRECISION_DECIMALS).sub(\n uint256(decimals[i])\n );\n tokenIndexes[address(_pooledTokens[i])] = i;\n }\n\n // Check _a, _fee, _adminFee, _withdrawFee, _allowlist parameters\n require(_a < SwapUtilsGuarded.MAX_A, \"_a exceeds maximum\");\n require(_fee < SwapUtilsGuarded.MAX_SWAP_FEE, \"_fee exceeds maximum\");\n require(\n _adminFee < SwapUtilsGuarded.MAX_ADMIN_FEE,\n \"_adminFee exceeds maximum\"\n );\n require(\n _withdrawFee < SwapUtilsGuarded.MAX_WITHDRAW_FEE,\n \"_withdrawFee exceeds maximum\"\n );\n require(\n _allowlist.getPoolCap(address(0x0)) == uint256(0x54dd1e),\n \"Allowlist check failed\"\n );\n\n // Initialize swapStorage struct\n swapStorage.lpToken = new LPTokenGuarded(\n lpTokenName,\n lpTokenSymbol,\n SwapUtilsGuarded.POOL_PRECISION_DECIMALS\n );\n swapStorage.pooledTokens = _pooledTokens;\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\n swapStorage.balances = new uint256[](_pooledTokens.length);\n swapStorage.initialA = _a.mul(SwapUtilsGuarded.A_PRECISION);\n swapStorage.futureA = _a.mul(SwapUtilsGuarded.A_PRECISION);\n swapStorage.initialATime = 0;\n swapStorage.futureATime = 0;\n swapStorage.swapFee = _fee;\n swapStorage.adminFee = _adminFee;\n swapStorage.defaultWithdrawFee = _withdrawFee;\n\n // Initialize variables related to guarding the initial deposits\n allowlist = _allowlist;\n guarded = true;\n }\n\n /*** MODIFIERS ***/\n\n /**\n * @notice Modifier to check deadline against current timestamp\n * @param deadline latest timestamp to accept this transaction\n */\n modifier deadlineCheck(uint256 deadline) {\n require(block.timestamp <= deadline, \"Deadline not met\");\n _;\n }\n\n /*** VIEW FUNCTIONS ***/\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @return A parameter\n */\n function getA() external view returns (uint256) {\n return swapStorage.getA();\n }\n\n /**\n * @notice Return A in its raw precision form\n * @dev See the StableSwap paper for details\n * @return A parameter in its raw precision form\n */\n function getAPrecise() external view returns (uint256) {\n return swapStorage.getAPrecise();\n }\n\n /**\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) public view returns (IERC20) {\n require(index < swapStorage.pooledTokens.length, \"Out of range\");\n return swapStorage.pooledTokens[index];\n }\n\n /**\n * @notice Return the index of the given token address. Reverts if no matching\n * token is found.\n * @param tokenAddress address of the token\n * @return the index of the given token address\n */\n function getTokenIndex(address tokenAddress) external view returns (uint8) {\n uint8 index = tokenIndexes[tokenAddress];\n require(\n address(getToken(index)) == tokenAddress,\n \"Token does not exist\"\n );\n return index;\n }\n\n /**\n * @notice Reads and returns the address of the allowlist that is set during deployment of this contract\n * @return the address of the allowlist contract casted to the IAllowlist interface\n */\n function getAllowlist() external view returns (IAllowlist) {\n return allowlist;\n }\n\n /**\n * @notice Return timestamp of last deposit of given address\n * @return timestamp of the last deposit made by the given address\n */\n function getDepositTimestamp(address user) external view returns (uint256) {\n return swapStorage.getDepositTimestamp(user);\n }\n\n /**\n * @notice Return current balance of the pooled token at given index\n * @param index the index of the token\n * @return current balance of the pooled token at given index with token's native precision\n */\n function getTokenBalance(uint8 index) external view returns (uint256) {\n require(index < swapStorage.pooledTokens.length, \"Index out of range\");\n return swapStorage.balances[index];\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice() external view returns (uint256) {\n return swapStorage.getVirtualPrice();\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256) {\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param account address that is depositing or withdrawing tokens\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(\n address account,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n return swapStorage.calculateTokenAmount(account, amounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param account the address that is withdrawing tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(address account, uint256 amount)\n external\n view\n returns (uint256[] memory)\n {\n return swapStorage.calculateRemoveLiquidity(account, amount);\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param account the address that is withdrawing tokens\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount) {\n (availableTokenAmount, ) = swapStorage.calculateWithdrawOneToken(\n account,\n tokenAmount,\n tokenIndex\n );\n }\n\n /**\n * @notice Calculate the fee that is applied when the given user withdraws. The withdraw fee\n * decays linearly over period of 4 weeks. For example, depositing and withdrawing right away\n * will charge you the full amount of withdraw fee. But withdrawing after 4 weeks will charge you\n * no additional fees.\n * @dev returned value should be divided by FEE_DENOMINATOR to convert to correct decimals\n * @param user address you want to calculate withdraw fee of\n * @return current withdraw fee of the user\n */\n function calculateCurrentWithdrawFee(address user)\n external\n view\n returns (uint256)\n {\n return swapStorage.calculateCurrentWithdrawFee(user);\n }\n\n /**\n * @notice This function reads the accumulated amount of admin fees of the token with given index\n * @param index Index of the pooled token\n * @return admin's token balance in the token's precision\n */\n function getAdminBalance(uint256 index) external view returns (uint256) {\n return swapStorage.getAdminBalance(index);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\n }\n\n /**\n * @notice Add liquidity to the pool with given amounts during guarded launch phase. Only users\n * with valid address and proof can successfully call this function. When this function is called\n * after the guarded release phase is over, the merkleProof is ignored.\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @param merkleProof data generated when constructing the allowlist merkle tree. Users can\n * get this data off chain. Even if the address is in the allowlist, users must include\n * a valid proof for this call to succeed. If the pool is no longer in the guarded release phase,\n * this parameter is ignored.\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline,\n bytes32[] calldata merkleProof\n )\n external\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.addLiquidity(amounts, minToMint, merkleProof);\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external nonReentrant deadlineCheck(deadline) returns (uint256[] memory) {\n return swapStorage.removeLiquidity(amount, minAmounts);\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n swapStorage.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the user withdraw fee. This function can only be called by\n * the pool token. Should be used to update the withdraw fee on transfer of pool tokens.\n * Transferring your pool token will reset the 4 weeks period. If the recipient is already\n * holding some pool tokens, the withdraw fee will be discounted in respective amounts.\n * @param recipient address of the recipient of pool token\n * @param transferAmount amount of pool token to transfer\n */\n function updateUserWithdrawFee(address recipient, uint256 transferAmount)\n external\n {\n require(\n msg.sender == address(swapStorage.lpToken),\n \"Only callable by pool token\"\n );\n swapStorage.updateUserWithdrawFee(recipient, transferAmount);\n }\n\n /**\n * @notice Withdraw all admin fees to the contract owner\n */\n function withdrawAdminFees() external onlyOwner {\n swapStorage.withdrawAdminFees(owner());\n }\n\n /**\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(uint256 newAdminFee) external onlyOwner {\n swapStorage.setAdminFee(newAdminFee);\n }\n\n /**\n * @notice Update the swap fee to be applied on swaps\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(uint256 newSwapFee) external onlyOwner {\n swapStorage.setSwapFee(newSwapFee);\n }\n\n /**\n * @notice Update the withdraw fee. This fee decays linearly over 4 weeks since\n * user's last deposit.\n * @param newWithdrawFee new withdraw fee to be applied on future deposits\n */\n function setDefaultWithdrawFee(uint256 newWithdrawFee) external onlyOwner {\n swapStorage.setDefaultWithdrawFee(newWithdrawFee);\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param futureA the new A to ramp towards\n * @param futureTime timestamp when the new A should be reached\n */\n function rampA(uint256 futureA, uint256 futureTime) external onlyOwner {\n swapStorage.rampA(futureA, futureTime);\n }\n\n /**\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\n */\n function stopRampA() external onlyOwner {\n swapStorage.stopRampA();\n }\n\n /**\n * @notice Disables the guarded launch phase, removing any limits on deposit amounts and addresses\n */\n function disableGuard() external onlyOwner {\n guarded = false;\n }\n\n /**\n * @notice Reads and returns current guarded status of the pool\n * @return guarded_ boolean value indicating whether the deposits should be guarded\n */\n function isGuarded() external view returns (bool) {\n return guarded;\n }\n}\n" + }, + "contracts/guarded/SwapUtilsGuarded.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// https://etherscan.io/address/0x2b7a5a5923eca5c00c6572cf3e8e08384f563f93#code\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"./LPTokenGuarded.sol\";\nimport \"../MathUtils.sol\";\n\n/**\n * @title SwapUtils library\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary SwapUtilsGuarded {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using MathUtils for uint256;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n struct Swap {\n // variables around the ramp management of A,\n // the amplification coefficient * n * (n - 1)\n // see https://www.curve.fi/stableswap-paper.pdf for details\n uint256 initialA;\n uint256 futureA;\n uint256 initialATime;\n uint256 futureATime;\n // fee calculation\n uint256 swapFee;\n uint256 adminFee;\n uint256 defaultWithdrawFee;\n LPTokenGuarded lpToken;\n // contract references for all tokens being pooled\n IERC20[] pooledTokens;\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\n uint256[] tokenPrecisionMultipliers;\n // the pool balance of each token, in the token's precision\n // the contract's actual token balance might differ\n uint256[] balances;\n mapping(address => uint256) depositTimestamp;\n mapping(address => uint256) withdrawFeeMultiplier;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n }\n\n // Struct storing variables used in calculation in addLiquidity function\n // to avoid stack too deep error\n struct AddLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n uint256 preciseA;\n }\n\n // Struct storing variables used in calculation in removeLiquidityImbalance function\n // to avoid stack too deep error\n struct RemoveLiquidityImbalanceInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n uint256 preciseA;\n }\n\n // the precision all pools tokens will be converted to\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Max swap fee is 1% or 100bps of each swap\n uint256 public constant MAX_SWAP_FEE = 10**8;\n\n // Max adminFee is 100% of the swapFee\n // adminFee does not add additional fee on top of swapFee\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\n // users but only on the earnings of LPs\n uint256 public constant MAX_ADMIN_FEE = 10**10;\n\n // Max withdrawFee is 1% of the value withdrawn\n // Fee will be redistributed to the LPs in the pool, rewarding\n // long term providers.\n uint256 public constant MAX_WITHDRAW_FEE = 10**8;\n\n // Constant value used as max loop limit\n uint256 private constant MAX_LOOP_LIMIT = 256;\n\n // Constant values used in ramping A calculations\n uint256 public constant A_PRECISION = 100;\n uint256 public constant MAX_A = 10**6;\n uint256 private constant MAX_A_CHANGE = 2;\n uint256 private constant MIN_RAMP_TIME = 14 days;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter\n */\n function getA(Swap storage self) external view returns (uint256) {\n return _getA(self);\n }\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter\n */\n function _getA(Swap storage self) internal view returns (uint256) {\n return _getAPrecise(self).div(A_PRECISION);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function getAPrecise(Swap storage self) external view returns (uint256) {\n return _getAPrecise(self);\n }\n\n /**\n * @notice Calculates and returns A based on the ramp settings\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\n uint256 t1 = self.futureATime; // time when ramp is finished\n uint256 a1 = self.futureA; // final A value when ramp is finished\n\n if (block.timestamp < t1) {\n uint256 t0 = self.initialATime; // time when ramp is started\n uint256 a0 = self.initialA; // initial A value when ramp is started\n if (a1 > a0) {\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.add(\n a1.sub(a0).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n } else {\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\n return\n a0.sub(\n a0.sub(a1).mul(block.timestamp.sub(t0)).div(t1.sub(t0))\n );\n }\n } else {\n return a1;\n }\n }\n\n /**\n * @notice Retrieves the timestamp of last deposit made by the given address\n * @param self Swap struct to read from\n * @return timestamp of last deposit\n */\n function getDepositTimestamp(Swap storage self, address user)\n external\n view\n returns (uint256)\n {\n return self.depositTimestamp[user];\n }\n\n /**\n * @notice Calculate the dy, the amount of selected token that user receives and\n * the fee of withdrawing in one token\n * @param account the address that is withdrawing\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @param self Swap struct to read from\n * @return the amount of token user will receive and the associated swap fee\n */\n function calculateWithdrawOneToken(\n Swap storage self,\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) public view returns (uint256, uint256) {\n uint256 dy;\n uint256 newY;\n\n (dy, newY) = calculateWithdrawOneTokenDY(self, tokenIndex, tokenAmount);\n\n // dy_0 (without fees)\n // dy, dy_0 - dy\n\n uint256 dySwapFee = _xp(self)[tokenIndex]\n .sub(newY)\n .div(self.tokenPrecisionMultipliers[tokenIndex])\n .sub(dy);\n\n dy = dy\n .mul(\n FEE_DENOMINATOR.sub(calculateCurrentWithdrawFee(self, account))\n )\n .div(FEE_DENOMINATOR);\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @return the d and the new y after withdrawing one token\n */\n function calculateWithdrawOneTokenDY(\n Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount\n ) internal view returns (uint256, uint256) {\n require(\n tokenIndex < self.pooledTokens.length,\n \"Token index out of range\"\n );\n\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self);\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\n v.preciseA = _getAPrecise(self);\n v.d0 = getD(xp, v.preciseA);\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(self.lpToken.totalSupply()));\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = _feePerToken(self);\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n uint256 xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] = xpi.sub(\n (\n (i == tokenIndex)\n ? xpi.mul(v.d1).div(v.d0).sub(v.newY)\n : xpi.sub(xpi.mul(v.d1).div(v.d0))\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\n );\n }\n\n uint256 dy = xpReduced[tokenIndex].sub(\n getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\n );\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\n\n return (dy, v.newY);\n }\n\n /**\n * @notice Calculate the price of a token in the pool with given\n * precision-adjusted balances and a particular D.\n *\n * @dev This is accomplished via solving the invariant iteratively.\n * See the StableSwap paper and Curve.fi implementation for further details.\n *\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\n * x_1**2 + b*x_1 = c\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\n *\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\n * @param tokenIndex Index of token we are calculating for.\n * @param xp a precision-adjusted set of pool balances. Array should be\n * the same cardinality as the pool.\n * @param d the stableswap invariant\n * @return the price of the token, in the same precision as in xp\n */\n function getYD(\n uint256 a,\n uint8 tokenIndex,\n uint256[] memory xp,\n uint256 d\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 c = d;\n uint256 s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < numTokens; i++) {\n if (i != tokenIndex) {\n s = s.add(xp[i]);\n c = c.mul(d).div(xp[i].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n }\n c = c.mul(d).mul(A_PRECISION).div(nA.mul(numTokens));\n\n uint256 b = s.add(d.mul(A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\n * as the pool.\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\n * See the StableSwap paper for details\n * @return the invariant, at the precision of the pool\n */\n function getD(uint256[] memory xp, uint256 a)\n internal\n pure\n returns (uint256)\n {\n uint256 numTokens = xp.length;\n uint256 s;\n for (uint256 i = 0; i < numTokens; i++) {\n s = s.add(xp[i]);\n }\n if (s == 0) {\n return 0;\n }\n\n uint256 prevD;\n uint256 d = s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n uint256 dP = d;\n for (uint256 j = 0; j < numTokens; j++) {\n dP = dP.mul(d).div(xp[j].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // dP = dP * D * D * D * ... overflow!\n }\n prevD = d;\n d = nA.mul(s).div(A_PRECISION).add(dP.mul(numTokens)).mul(d).div(\n nA.sub(A_PRECISION).mul(d).div(A_PRECISION).add(\n numTokens.add(1).mul(dP)\n )\n );\n if (d.within1(prevD)) {\n return d;\n }\n }\n\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\n // function which does not rely on D.\n revert(\"D does not converge\");\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on self Swap struct\n * @param self Swap struct to read from\n * @return The invariant, at the precision of the pool\n */\n function getD(Swap storage self) internal view returns (uint256) {\n return getD(_xp(self), _getAPrecise(self));\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers\n ) internal pure returns (uint256[] memory) {\n uint256 numTokens = balances.length;\n require(\n numTokens == precisionMultipliers.length,\n \"Balances must match multipliers\"\n );\n uint256[] memory xp = new uint256[](numTokens);\n for (uint256 i = 0; i < numTokens; i++) {\n xp[i] = balances[i].mul(precisionMultipliers[i]);\n }\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @param balances array of balances to scale\n * @return balances array \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(Swap storage self, uint256[] memory balances)\n internal\n view\n returns (uint256[] memory)\n {\n return _xp(balances, self.tokenPrecisionMultipliers);\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\n return _xp(self.balances, self.tokenPrecisionMultipliers);\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice(Swap storage self)\n external\n view\n returns (uint256)\n {\n uint256 d = getD(_xp(self), _getAPrecise(self));\n uint256 supply = self.lpToken.totalSupply();\n if (supply > 0) {\n return\n d.mul(10**uint256(ERC20(self.lpToken).decimals())).div(supply);\n }\n return 0;\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much TO token\n * the user should receive on swap.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param x the new total amount of FROM token\n * @param xp balances of the tokens in the pool\n * @return the amount of TO token that should remain in the pool\n */\n function getY(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 x,\n uint256[] memory xp\n ) internal view returns (uint256) {\n uint256 numTokens = self.pooledTokens.length;\n require(\n tokenIndexFrom != tokenIndexTo,\n \"Can't compare token to itself\"\n );\n require(\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\n \"Tokens must be in pool\"\n );\n\n uint256 a = _getAPrecise(self);\n uint256 d = getD(xp, a);\n uint256 c = d;\n uint256 s;\n uint256 nA = numTokens.mul(a);\n\n uint256 _x;\n for (uint256 i = 0; i < numTokens; i++) {\n if (i == tokenIndexFrom) {\n _x = x;\n } else if (i != tokenIndexTo) {\n _x = xp[i];\n } else {\n continue;\n }\n s = s.add(_x);\n c = c.mul(d).div(_x.mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n c = c.mul(d).mul(A_PRECISION).div(nA.mul(numTokens));\n uint256 b = s.add(d.mul(A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n\n // iterative approximation\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Externally calculates a swap between two tokens.\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(self, tokenIndexFrom, tokenIndexTo, dx);\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n * @return dyFee the associated fee\n */\n function _calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory xp = _xp(self);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 x = dx.mul(self.tokenPrecisionMultipliers[tokenIndexFrom]).add(\n xp[tokenIndexFrom]\n );\n uint256 y = getY(self, tokenIndexFrom, tokenIndexTo, x, xp);\n dy = xp[tokenIndexTo].sub(y).sub(1);\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n dy = dy.sub(dyFee).div(self.tokenPrecisionMultipliers[tokenIndexTo]);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of\n * LP tokens\n *\n * @param account the address that is removing liquidity. required for withdraw fee calculation\n * @param amount the amount of LP tokens that would to be burned on\n * withdrawal\n * @return array of amounts of tokens user will receive\n */\n function calculateRemoveLiquidity(\n Swap storage self,\n address account,\n uint256 amount\n ) external view returns (uint256[] memory) {\n return _calculateRemoveLiquidity(self, account, amount);\n }\n\n function _calculateRemoveLiquidity(\n Swap storage self,\n address account,\n uint256 amount\n ) internal view returns (uint256[] memory) {\n uint256 totalSupply = self.lpToken.totalSupply();\n require(amount <= totalSupply, \"Cannot exceed total supply\");\n\n uint256 feeAdjustedAmount = amount\n .mul(\n FEE_DENOMINATOR.sub(calculateCurrentWithdrawFee(self, account))\n )\n .div(FEE_DENOMINATOR);\n\n uint256[] memory amounts = new uint256[](self.pooledTokens.length);\n\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n amounts[i] = self.balances[i].mul(feeAdjustedAmount).div(\n totalSupply\n );\n }\n return amounts;\n }\n\n /**\n * @notice Calculate the fee that is applied when the given user withdraws.\n * Withdraw fee decays linearly over 4 weeks.\n * @param user address you want to calculate withdraw fee of\n * @return current withdraw fee of the user\n */\n function calculateCurrentWithdrawFee(Swap storage self, address user)\n public\n view\n returns (uint256)\n {\n uint256 endTime = self.depositTimestamp[user].add(4 weeks);\n if (endTime > block.timestamp) {\n uint256 timeLeftover = endTime.sub(block.timestamp);\n return\n self\n .defaultWithdrawFee\n .mul(self.withdrawFeeMultiplier[user])\n .mul(timeLeftover)\n .div(4 weeks)\n .div(FEE_DENOMINATOR);\n }\n return 0;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param account address of the account depositing or withdrawing tokens\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n Swap storage self,\n address account,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 numTokens = self.pooledTokens.length;\n uint256 a = _getAPrecise(self);\n uint256 d0 = getD(_xp(self, self.balances), a);\n uint256[] memory balances1 = self.balances;\n for (uint256 i = 0; i < numTokens; i++) {\n if (deposit) {\n balances1[i] = balances1[i].add(amounts[i]);\n } else {\n balances1[i] = balances1[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n }\n uint256 d1 = getD(_xp(self, balances1), a);\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return d1.sub(d0).mul(totalSupply).div(d0);\n } else {\n return\n d0.sub(d1).mul(totalSupply).div(d0).mul(FEE_DENOMINATOR).div(\n FEE_DENOMINATOR.sub(\n calculateCurrentWithdrawFee(self, account)\n )\n );\n }\n }\n\n /**\n * @notice return accumulated amount of admin fees of the token with given index\n * @param self Swap struct to read from\n * @param index Index of the pooled token\n * @return admin balance in the token's precision\n */\n function getAdminBalance(Swap storage self, uint256 index)\n external\n view\n returns (uint256)\n {\n require(index < self.pooledTokens.length, \"Token index out of range\");\n return\n self.pooledTokens[index].balanceOf(address(this)).sub(\n self.balances[index]\n );\n }\n\n /**\n * @notice internal helper function to calculate fee per token multiplier used in\n * swap fee calculations\n * @param self Swap struct to read from\n */\n function _feePerToken(Swap storage self) internal view returns (uint256) {\n return\n self.swapFee.mul(self.pooledTokens.length).div(\n self.pooledTokens.length.sub(1).mul(4)\n );\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n require(\n dx <= self.pooledTokens[tokenIndexFrom].balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = self.pooledTokens[tokenIndexFrom].balanceOf(\n address(this)\n );\n self.pooledTokens[tokenIndexFrom].safeTransferFrom(\n msg.sender,\n address(this),\n dx\n );\n\n // Use the actual transferred amount for AMM math\n uint256 transferredDx = self\n .pooledTokens[tokenIndexFrom]\n .balanceOf(address(this))\n .sub(beforeBalance);\n\n (uint256 dy, uint256 dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n transferredDx\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\n self.tokenPrecisionMultipliers[tokenIndexTo]\n );\n\n self.balances[tokenIndexFrom] = self.balances[tokenIndexFrom].add(\n transferredDx\n );\n self.balances[tokenIndexTo] = self.balances[tokenIndexTo].sub(dy).sub(\n dyAdminFee\n );\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(\n msg.sender,\n transferredDx,\n dy,\n tokenIndexFrom,\n tokenIndexTo\n );\n\n return dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param merkleProof bytes32 array that will be used to prove the existence of the caller's address in the list of\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n Swap storage self,\n uint256[] memory amounts,\n uint256 minToMint,\n bytes32[] calldata merkleProof\n ) external returns (uint256) {\n require(\n amounts.length == self.pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n uint256[] memory fees = new uint256[](self.pooledTokens.length);\n\n // current state\n AddLiquidityInfo memory v = AddLiquidityInfo(0, 0, 0, 0);\n\n if (self.lpToken.totalSupply() != 0) {\n v.d0 = getD(self);\n }\n uint256[] memory newBalances = self.balances;\n\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n require(\n self.lpToken.totalSupply() != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = self.pooledTokens[i].balanceOf(\n address(this)\n );\n self.pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] = self.pooledTokens[i].balanceOf(address(this)).sub(\n beforeBalance\n );\n }\n\n newBalances[i] = self.balances[i].add(amounts[i]);\n }\n\n // invariant after change\n v.preciseA = _getAPrecise(self);\n v.d1 = getD(_xp(self, newBalances), v.preciseA);\n require(v.d1 > v.d0, \"D should increase\");\n\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n if (self.lpToken.totalSupply() != 0) {\n uint256 feePerToken = _feePerToken(self);\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(self.balances[i]).div(v.d0);\n fees[i] = feePerToken\n .mul(idealBalance.difference(newBalances[i]))\n .div(FEE_DENOMINATOR);\n self.balances[i] = newBalances[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n newBalances[i] = newBalances[i].sub(fees[i]);\n }\n v.d2 = getD(_xp(self, newBalances), v.preciseA);\n } else {\n // the initial depositor doesn't pay fees\n self.balances = newBalances;\n }\n\n uint256 toMint;\n if (self.lpToken.totalSupply() == 0) {\n toMint = v.d1;\n } else {\n toMint = v.d2.sub(v.d0).mul(self.lpToken.totalSupply()).div(v.d0);\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n self.lpToken.mint(msg.sender, toMint, merkleProof);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n self.lpToken.totalSupply()\n );\n\n return toMint;\n }\n\n /**\n * @notice Update the withdraw fee for `user`. If the user is currently\n * not providing liquidity in the pool, sets to default value. If not, recalculate\n * the starting withdraw fee based on the last deposit's time & amount relative\n * to the new deposit.\n *\n * @param self Swap struct to read from and write to\n * @param user address of the user depositing tokens\n * @param toMint amount of pool tokens to be minted\n */\n function updateUserWithdrawFee(\n Swap storage self,\n address user,\n uint256 toMint\n ) external {\n _updateUserWithdrawFee(self, user, toMint);\n }\n\n function _updateUserWithdrawFee(\n Swap storage self,\n address user,\n uint256 toMint\n ) internal {\n // If token is transferred to address 0 (or burned), don't update the fee.\n if (user == address(0)) {\n return;\n }\n if (self.defaultWithdrawFee == 0) {\n // If current fee is set to 0%, set multiplier to FEE_DENOMINATOR\n self.withdrawFeeMultiplier[user] = FEE_DENOMINATOR;\n } else {\n // Otherwise, calculate appropriate discount based on last deposit amount\n uint256 currentFee = calculateCurrentWithdrawFee(self, user);\n uint256 currentBalance = self.lpToken.balanceOf(user);\n\n // ((currentBalance * currentFee) + (toMint * defaultWithdrawFee)) * FEE_DENOMINATOR /\n // ((toMint + currentBalance) * defaultWithdrawFee)\n self.withdrawFeeMultiplier[user] = currentBalance\n .mul(currentFee)\n .add(toMint.mul(self.defaultWithdrawFee))\n .mul(FEE_DENOMINATOR)\n .div(toMint.add(currentBalance).mul(self.defaultWithdrawFee));\n }\n self.depositTimestamp[user] = block.timestamp;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param self Swap struct to read from and write to\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @return amounts of tokens the user received\n */\n function removeLiquidity(\n Swap storage self,\n uint256 amount,\n uint256[] calldata minAmounts\n ) external returns (uint256[] memory) {\n require(amount <= self.lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(\n minAmounts.length == self.pooledTokens.length,\n \"minAmounts must match poolTokens\"\n );\n\n uint256[] memory amounts = _calculateRemoveLiquidity(\n self,\n msg.sender,\n amount\n );\n\n for (uint256 i = 0; i < amounts.length; i++) {\n require(amounts[i] >= minAmounts[i], \"amounts[i] < minAmounts[i]\");\n self.balances[i] = self.balances[i].sub(amounts[i]);\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n self.lpToken.burnFrom(msg.sender, amount);\n\n emit RemoveLiquidity(msg.sender, amounts, self.lpToken.totalSupply());\n\n return amounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n uint256 totalSupply = self.lpToken.totalSupply();\n uint256 numTokens = self.pooledTokens.length;\n require(\n tokenAmount <= self.lpToken.balanceOf(msg.sender),\n \">LP.balanceOf\"\n );\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 dyFee;\n uint256 dy;\n\n (dy, dyFee) = calculateWithdrawOneToken(\n self,\n msg.sender,\n tokenAmount,\n tokenIndex\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\n );\n self.lpToken.burnFrom(msg.sender, tokenAmount);\n self.pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n Swap storage self,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n require(\n amounts.length == self.pooledTokens.length,\n \"Amounts should match pool tokens\"\n );\n require(\n maxBurnAmount <= self.lpToken.balanceOf(msg.sender) &&\n maxBurnAmount != 0,\n \">LP.balanceOf\"\n );\n\n RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(\n 0,\n 0,\n 0,\n 0\n );\n\n uint256 tokenSupply = self.lpToken.totalSupply();\n uint256 feePerToken = _feePerToken(self);\n\n uint256[] memory balances1 = self.balances;\n\n v.preciseA = _getAPrecise(self);\n v.d0 = getD(_xp(self), v.preciseA);\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n balances1[i] = balances1[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n v.d1 = getD(_xp(self, balances1), v.preciseA);\n uint256[] memory fees = new uint256[](self.pooledTokens.length);\n\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(self.balances[i]).div(v.d0);\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\n self.balances[i] = balances1[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n balances1[i] = balances1[i].sub(fees[i]);\n }\n\n v.d2 = getD(_xp(self, balances1), v.preciseA);\n\n uint256 tokenAmount = v.d0.sub(v.d2).mul(tokenSupply).div(v.d0);\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n tokenAmount = tokenAmount.add(1).mul(FEE_DENOMINATOR).div(\n FEE_DENOMINATOR.sub(calculateCurrentWithdrawFee(self, msg.sender))\n );\n\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n self.lpToken.burnFrom(msg.sender, tokenAmount);\n\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n tokenSupply.sub(tokenAmount)\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice withdraw all admin fees to a given address\n * @param self Swap struct to withdraw fees from\n * @param to Address to send the fees to\n */\n function withdrawAdminFees(Swap storage self, address to) external {\n for (uint256 i = 0; i < self.pooledTokens.length; i++) {\n IERC20 token = self.pooledTokens[i];\n uint256 balance = token.balanceOf(address(this)).sub(\n self.balances[i]\n );\n if (balance != 0) {\n token.safeTransfer(to, balance);\n }\n }\n }\n\n /**\n * @notice Sets the admin fee\n * @dev adminFee cannot be higher than 100% of the swap fee\n * @param self Swap struct to update\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\n require(newAdminFee <= MAX_ADMIN_FEE, \"Fee is too high\");\n self.adminFee = newAdminFee;\n\n emit NewAdminFee(newAdminFee);\n }\n\n /**\n * @notice update the swap fee\n * @dev fee cannot be higher than 1% of each swap\n * @param self Swap struct to update\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\n require(newSwapFee <= MAX_SWAP_FEE, \"Fee is too high\");\n self.swapFee = newSwapFee;\n\n emit NewSwapFee(newSwapFee);\n }\n\n /**\n * @notice update the default withdraw fee. This also affects deposits made in the past as well.\n * @param self Swap struct to update\n * @param newWithdrawFee new withdraw fee to be applied\n */\n function setDefaultWithdrawFee(Swap storage self, uint256 newWithdrawFee)\n external\n {\n require(newWithdrawFee <= MAX_WITHDRAW_FEE, \"Fee is too high\");\n self.defaultWithdrawFee = newWithdrawFee;\n\n emit NewWithdrawFee(newWithdrawFee);\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param self Swap struct to update\n * @param futureA_ the new A to ramp towards\n * @param futureTime_ timestamp when the new A should be reached\n */\n function rampA(\n Swap storage self,\n uint256 futureA_,\n uint256 futureTime_\n ) external {\n require(\n block.timestamp >= self.initialATime.add(1 days),\n \"Wait 1 day before starting ramp\"\n );\n require(\n futureTime_ >= block.timestamp.add(MIN_RAMP_TIME),\n \"Insufficient ramp time\"\n );\n require(\n futureA_ > 0 && futureA_ < MAX_A,\n \"futureA_ must be > 0 and < MAX_A\"\n );\n\n uint256 initialAPrecise = _getAPrecise(self);\n uint256 futureAPrecise = futureA_.mul(A_PRECISION);\n\n if (futureAPrecise < initialAPrecise) {\n require(\n futureAPrecise.mul(MAX_A_CHANGE) >= initialAPrecise,\n \"futureA_ is too small\"\n );\n } else {\n require(\n futureAPrecise <= initialAPrecise.mul(MAX_A_CHANGE),\n \"futureA_ is too large\"\n );\n }\n\n self.initialA = initialAPrecise;\n self.futureA = futureAPrecise;\n self.initialATime = block.timestamp;\n self.futureATime = futureTime_;\n\n emit RampA(\n initialAPrecise,\n futureAPrecise,\n block.timestamp,\n futureTime_\n );\n }\n\n /**\n * @notice Stops ramping A immediately. Once this function is called, rampA()\n * cannot be called for another 24 hours\n * @param self Swap struct to update\n */\n function stopRampA(Swap storage self) external {\n require(self.futureATime > block.timestamp, \"Ramp is already stopped\");\n uint256 currentA = _getAPrecise(self);\n\n self.initialA = currentA;\n self.futureA = currentA;\n self.initialATime = block.timestamp;\n self.futureATime = block.timestamp;\n\n emit StopRampA(currentA, block.timestamp);\n }\n}\n" + }, + "contracts/helper/BaseBoringBatchable.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\n// solhint-disable avoid-low-level-calls\n// solhint-disable no-inline-assembly\n\n// Audit on 5-Jan-2021 by Keno and BoringCrypto\n// WARNING!!!\n// Combining BoringBatchable with msg.value can cause double spending issues\n// https://www.paradigm.xyz/2021/08/two-rights-might-make-a-wrong/\n\ncontract BaseBoringBatchable {\n /// @dev Helper function to extract a useful revert message from a failed call.\n /// If the returned data is malformed or not correctly abi encoded then this call can fail itself.\n function _getRevertMsg(bytes memory _returnData)\n internal\n pure\n returns (string memory)\n {\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n if (_returnData.length < 68) return \"Transaction reverted silently\";\n\n assembly {\n // Slice the sighash.\n _returnData := add(_returnData, 0x04)\n }\n return abi.decode(_returnData, (string)); // All that remains is the revert string\n }\n\n /// @notice Allows batched call to self (this contract).\n /// @param calls An array of inputs for each call.\n /// @param revertOnFail If True then reverts after a failed call and stops doing further calls.\n // F1: External is ok here because this is the batch function, adding it to a batch makes no sense\n // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value\n // C3: The length of the loop is fully under user control, so can't be exploited\n // C7: Delegatecall is only used on the same contract, so it's safe\n function batch(bytes[] calldata calls, bool revertOnFail) external payable {\n for (uint256 i = 0; i < calls.length; i++) {\n (bool success, bytes memory result) = address(this).delegatecall(\n calls[i]\n );\n if (!success && revertOnFail) {\n revert(_getRevertMsg(result));\n }\n }\n }\n}\n" + }, + "contracts/helper/FlashLoanBorrowerExample.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"../interfaces/IFlashLoanReceiver.sol\";\nimport \"../interfaces/ISwapFlashLoan.sol\";\nimport \"hardhat/console.sol\";\n\ncontract FlashLoanBorrowerExample is IFlashLoanReceiver {\n using SafeMath for uint256;\n\n // Typical executeOperation function should do the 3 following actions\n // 1. Check if the flashLoan was successful\n // 2. Do actions with the borrowed tokens\n // 3. Repay the debt to the `pool`\n function executeOperation(\n address pool,\n address token,\n uint256 amount,\n uint256 fee,\n bytes calldata params\n ) external override {\n // 1. Check if the flashLoan was valid\n require(\n IERC20(token).balanceOf(address(this)) >= amount,\n \"flashloan is broken?\"\n );\n\n // 2. Do actions with the borrowed token\n bytes32 paramsHash = keccak256(params);\n if (paramsHash == keccak256(bytes(\"dontRepayDebt\"))) {\n return;\n } else if (paramsHash == keccak256(bytes(\"reentrancy_addLiquidity\"))) {\n ISwapFlashLoan(pool).addLiquidity(\n new uint256[](0),\n 0,\n block.timestamp\n );\n } else if (paramsHash == keccak256(bytes(\"reentrancy_swap\"))) {\n ISwapFlashLoan(pool).swap(1, 0, 1e6, 0, now);\n } else if (\n paramsHash == keccak256(bytes(\"reentrancy_removeLiquidity\"))\n ) {\n ISwapFlashLoan(pool).removeLiquidity(1e18, new uint256[](0), now);\n } else if (\n paramsHash == keccak256(bytes(\"reentrancy_removeLiquidityOneToken\"))\n ) {\n ISwapFlashLoan(pool).removeLiquidityOneToken(1e18, 0, 1e18, now);\n }\n\n // 3. Payback debt\n uint256 totalDebt = amount.add(fee);\n IERC20(token).transfer(pool, totalDebt);\n }\n\n function flashLoan(\n ISwapFlashLoan swap,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external {\n swap.flashLoan(address(this), token, amount, params);\n }\n}\n" + }, + "contracts/helper/GaugeHelperContract.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\nimport \"../interfaces/IMasterRegistry.sol\";\nimport \"../interfaces/IPoolRegistry.sol\";\n\ninterface ILiquidityGaugeV5 {\n struct Reward {\n address token;\n address distributor;\n uint256 period_finish;\n uint256 rate;\n uint256 last_update;\n uint256 integral;\n }\n\n function lp_token() external view returns (address);\n\n // reward_count\n function reward_count() external view returns (uint256);\n\n function reward_tokens(uint256) external view returns (address);\n\n function reward_data(address) external view returns (Reward memory);\n\n function claimable_reward(address, address) external view returns (uint256);\n}\n\ninterface ILPToken {\n function owner() external view returns (address);\n}\n\ncontract GaugeHelperContract {\n IMasterRegistry public immutable MASTER_REGISTRY;\n bytes32 public constant POOL_REGISTRY_NAME =\n 0x506f6f6c52656769737472790000000000000000000000000000000000000000;\n\n constructor(address _masterRegistry) public {\n MASTER_REGISTRY = IMasterRegistry(_masterRegistry);\n }\n\n function gaugeToPoolAddress(address gauge) public view returns (address) {\n try ILiquidityGaugeV5(gauge).lp_token() returns (\n address saddleLpToken\n ) {\n try ILPToken(saddleLpToken).owner() returns (\n address saddlePoolAddress\n ) {\n return saddlePoolAddress;\n } catch {\n return address(0);\n }\n } catch {\n // Returns zero address if the gauge is not directly using saddle LP token\n return address(0);\n }\n }\n\n function gaugeToPoolData(address gauge)\n public\n view\n returns (IPoolRegistry.PoolData memory)\n {\n // Get PoolRegistry from MasterRegistry\n IPoolRegistry poolRegistry = IPoolRegistry(\n MASTER_REGISTRY.resolveNameToLatestAddress(POOL_REGISTRY_NAME)\n );\n\n // Try getting pool data\n try poolRegistry.getPoolData(gaugeToPoolAddress(gauge)) returns (\n IPoolRegistry.PoolData memory poolData\n ) {\n return poolData;\n } catch {\n // Returns zero address if the gauge is not directly using saddle LP token\n IPoolRegistry.PoolData memory poolData;\n return poolData;\n }\n }\n\n function getGaugeRewards(address gauge)\n public\n view\n returns (ILiquidityGaugeV5.Reward[] memory)\n {\n uint256 rewardCount = ILiquidityGaugeV5(gauge).reward_count();\n address[] memory rewardTokens = new address[](rewardCount);\n for (uint256 i = 0; i < rewardCount; i++) {\n rewardTokens[i] = ILiquidityGaugeV5(gauge).reward_tokens(i);\n }\n // call reward_data() will all reward token addresses\n ILiquidityGaugeV5.Reward[]\n memory rewardData = new ILiquidityGaugeV5.Reward[](rewardCount);\n for (uint256 i = 0; i < rewardCount; i++) {\n rewardData[i] = ILiquidityGaugeV5(gauge).reward_data(\n rewardTokens[i]\n );\n }\n return rewardData;\n }\n\n function getClaimableRewards(address gauge, address user)\n public\n view\n returns (uint256[] memory)\n {\n uint256 rewardCount = ILiquidityGaugeV5(gauge).reward_count();\n address[] memory rewardTokens = new address[](rewardCount);\n for (uint256 i = 0; i < rewardCount; i++) {\n rewardTokens[i] = ILiquidityGaugeV5(gauge).reward_tokens(i);\n }\n // call reward_data() will all reward token addresses\n uint256[] memory claimableRewards = new uint256[](rewardCount);\n for (uint256 i = 0; i < rewardCount; i++) {\n claimableRewards[i] = ILiquidityGaugeV5(gauge).claimable_reward(\n user,\n rewardTokens[i]\n );\n }\n return claimableRewards;\n }\n}\n" + }, + "contracts/helper/GenericERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title Generic ERC20 token\n * @notice This contract simulates a generic ERC20 token that is mintable and burnable.\n */\ncontract GenericERC20 is ERC20, Ownable {\n /**\n * @notice Deploy this contract with given name, symbol, and decimals\n * @dev the caller of this constructor will become the owner of this contract\n * @param name_ name of this token\n * @param symbol_ symbol of this token\n * @param decimals_ number of decimals this token will be based on\n */\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public ERC20(name_, symbol_) {\n _setupDecimals(decimals_);\n }\n\n /**\n * @notice Mints given amount of tokens to recipient\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n */\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(amount != 0, \"amount == 0\");\n _mint(recipient, amount);\n }\n}\n" + }, + "contracts/helper/GenericERC20NoOwnerFunction.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/**\n * @title Generic ERC20 token\n * @notice This contract simulates a generic ERC20 token that is mintable and burnable.\n */\ncontract GenericERC20NoOwnerFunction is ERC20 {\n address private immutable _owner;\n\n /**\n * @notice Deploy this contract with given name, symbol, and decimals\n * @dev the caller of this constructor will become the owner of this contract\n * @param name_ name of this token\n * @param symbol_ symbol of this token\n * @param decimals_ number of decimals this token will be based on\n */\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) public ERC20(name_, symbol_) {\n _setupDecimals(decimals_);\n _owner = msg.sender;\n }\n\n /**\n * @notice Mints given amount of tokens to recipient\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n */\n function mint(address recipient, uint256 amount) external {\n require(amount != 0, \"amount == 0\");\n require(msg.sender == _owner, \"only owner can mint\");\n _mint(recipient, amount);\n }\n}\n" + }, + "contracts/helper/test/TestMathUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"../../MathUtils.sol\";\n\ncontract TestMathUtils {\n using MathUtils for uint256;\n\n function difference(uint256 a, uint256 b) public pure returns (uint256) {\n return a.difference(b);\n }\n\n function within1(uint256 a, uint256 b) public pure returns (bool) {\n return a.within1(b);\n }\n}\n" + }, + "contracts/helper/test/TestSwapReturnValues.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"../../interfaces/ISwap.sol\";\nimport \"hardhat/console.sol\";\n\ncontract TestSwapReturnValues {\n using SafeMath for uint256;\n\n ISwap public swap;\n IERC20 public lpToken;\n uint8 public n;\n\n uint256 public constant MAX_INT = 2**256 - 1;\n\n constructor(\n ISwap swapContract,\n IERC20 lpTokenContract,\n uint8 numOfTokens\n ) public {\n swap = swapContract;\n lpToken = lpTokenContract;\n n = numOfTokens;\n\n // Pre-approve tokens\n for (uint8 i; i < n; i++) {\n swap.getToken(i).approve(address(swap), MAX_INT);\n }\n lpToken.approve(address(swap), MAX_INT);\n }\n\n function test_swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) public {\n uint256 balanceBefore = swap.getToken(tokenIndexTo).balanceOf(\n address(this)\n );\n uint256 returnValue = swap.swap(\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy,\n block.timestamp\n );\n uint256 balanceAfter = swap.getToken(tokenIndexTo).balanceOf(\n address(this)\n );\n\n console.log(\n \"swap: Expected %s, got %s\",\n balanceAfter.sub(balanceBefore),\n returnValue\n );\n\n require(\n returnValue == balanceAfter.sub(balanceBefore),\n \"swap()'s return value does not match received amount\"\n );\n }\n\n function test_addLiquidity(uint256[] calldata amounts, uint256 minToMint)\n public\n {\n uint256 balanceBefore = lpToken.balanceOf(address(this));\n uint256 returnValue = swap.addLiquidity(amounts, minToMint, MAX_INT);\n uint256 balanceAfter = lpToken.balanceOf(address(this));\n\n console.log(\n \"addLiquidity: Expected %s, got %s\",\n balanceAfter.sub(balanceBefore),\n returnValue\n );\n\n require(\n returnValue == balanceAfter.sub(balanceBefore),\n \"addLiquidity()'s return value does not match minted amount\"\n );\n }\n\n function test_removeLiquidity(uint256 amount, uint256[] memory minAmounts)\n public\n {\n uint256[] memory balanceBefore = new uint256[](n);\n uint256[] memory balanceAfter = new uint256[](n);\n\n for (uint8 i = 0; i < n; i++) {\n balanceBefore[i] = swap.getToken(i).balanceOf(address(this));\n }\n\n uint256[] memory returnValue = swap.removeLiquidity(\n amount,\n minAmounts,\n MAX_INT\n );\n\n for (uint8 i = 0; i < n; i++) {\n balanceAfter[i] = swap.getToken(i).balanceOf(address(this));\n console.log(\n \"removeLiquidity: Expected %s, got %s\",\n balanceAfter[i].sub(balanceBefore[i]),\n returnValue[i]\n );\n require(\n balanceAfter[i].sub(balanceBefore[i]) == returnValue[i],\n \"removeLiquidity()'s return value does not match received amounts of tokens\"\n );\n }\n }\n\n function test_removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount\n ) public {\n uint256 balanceBefore = lpToken.balanceOf(address(this));\n uint256 returnValue = swap.removeLiquidityImbalance(\n amounts,\n maxBurnAmount,\n MAX_INT\n );\n uint256 balanceAfter = lpToken.balanceOf(address(this));\n\n console.log(\n \"removeLiquidityImbalance: Expected %s, got %s\",\n balanceBefore.sub(balanceAfter),\n returnValue\n );\n\n require(\n returnValue == balanceBefore.sub(balanceAfter),\n \"removeLiquidityImbalance()'s return value does not match burned lpToken amount\"\n );\n }\n\n function test_removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) public {\n uint256 balanceBefore = swap.getToken(tokenIndex).balanceOf(\n address(this)\n );\n uint256 returnValue = swap.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount,\n MAX_INT\n );\n uint256 balanceAfter = swap.getToken(tokenIndex).balanceOf(\n address(this)\n );\n\n console.log(\n \"removeLiquidityOneToken: Expected %s, got %s\",\n balanceAfter.sub(balanceBefore),\n returnValue\n );\n\n require(\n returnValue == balanceAfter.sub(balanceBefore),\n \"removeLiquidityOneToken()'s return value does not match received token amount\"\n );\n }\n}\n" + }, + "contracts/interfaces/IAllowlist.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\ninterface IAllowlist {\n function getPoolAccountLimit(address poolAddress)\n external\n view\n returns (uint256);\n\n function getPoolCap(address poolAddress) external view returns (uint256);\n\n function verifyAddress(address account, bytes32[] calldata merkleProof)\n external\n returns (bool);\n}\n" + }, + "contracts/interfaces/IFlashLoanReceiver.sol": { + "content": "// SPDX-License-Identifier: AGPL-3.0-only\n\npragma solidity 0.6.12;\n\n/**\n * @title IFlashLoanReceiver interface\n * @notice Interface for the Saddle fee IFlashLoanReceiver. Modified from Aave's IFlashLoanReceiver interface.\n * https://github.com/aave/aave-protocol/blob/4b4545fb583fd4f400507b10f3c3114f45b8a037/contracts/flashloan/interfaces/IFlashLoanReceiver.sol\n * @author Aave\n * @dev implement this interface to develop a flashloan-compatible flashLoanReceiver contract\n **/\ninterface IFlashLoanReceiver {\n function executeOperation(\n address pool,\n address token,\n uint256 amount,\n uint256 fee,\n bytes calldata params\n ) external;\n}\n" + }, + "contracts/interfaces/IMasterRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0;\npragma experimental ABIEncoderV2;\n\ninterface IMasterRegistry {\n /* Structs */\n\n struct ReverseRegistryData {\n bytes32 name;\n uint256 version;\n }\n\n /* Functions */\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param registryName name for the registry\n * @param registryAddress address of the new registry\n */\n function addRegistry(bytes32 registryName, address registryAddress)\n external\n payable;\n\n /**\n * @notice Resolves a name to the latest registry address. Reverts if no match is found.\n * @param name name for the registry\n * @return address address of the latest registry with the matching name\n */\n function resolveNameToLatestAddress(bytes32 name)\n external\n view\n returns (address);\n\n /**\n * @notice Resolves a name and version to an address. Reverts if there is no registry with given name and version.\n * @param name address of the registry you want to resolve to\n * @param version version of the registry you want to resolve to\n */\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\n external\n view\n returns (address);\n\n /**\n * @notice Resolves a name to an array of all addresses. Reverts if no match is found.\n * @param name name for the registry\n * @return address address of the latest registry with the matching name\n */\n function resolveNameToAllAddresses(bytes32 name)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Resolves an address to registry entry data.\n * @param registryAddress address of a registry you want to resolve\n * @return name name of the resolved registry\n * @return version version of the resolved registry\n * @return isLatest boolean flag of whether the given address is the latest version of the given registries with\n * matching name\n */\n function resolveAddressToRegistryData(address registryAddress)\n external\n view\n returns (\n bytes32 name,\n uint256 version,\n bool isLatest\n );\n}\n" + }, + "contracts/interfaces/IMetaSwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./ISwap.sol\";\n\ninterface IMetaSwap {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function isGuarded() external view returns (bool);\n\n function metaSwapStorage()\n external\n view\n returns (\n address baseSwap,\n uint256 baseVirtualPrice,\n uint256 baseCacheLastUpdated\n );\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateSwapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) external;\n\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwap baseSwap\n ) external;\n\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function swapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n}\n" + }, + "contracts/interfaces/IMetaSwapDeposit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./ISwap.sol\";\nimport \"./IMetaSwap.sol\";\n\ninterface IMetaSwapDeposit {\n function initialize(\n ISwap _baseSwap,\n IMetaSwap _metaSwap,\n IERC20 _metaLPToken\n ) external;\n}\n" + }, + "contracts/interfaces/IPoolRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IPoolRegistry {\n /* Structs */\n\n struct PoolInputData {\n address poolAddress;\n uint8 typeOfAsset;\n bytes32 poolName;\n address targetAddress;\n address metaSwapDepositAddress;\n bool isSaddleApproved;\n bool isRemoved;\n bool isGuarded;\n }\n\n struct PoolData {\n address poolAddress;\n address lpToken;\n uint8 typeOfAsset;\n bytes32 poolName;\n address targetAddress;\n IERC20[] tokens;\n IERC20[] underlyingTokens;\n address basePoolAddress;\n address metaSwapDepositAddress;\n bool isSaddleApproved;\n bool isRemoved;\n bool isGuarded;\n }\n\n struct SwapStorageData {\n uint256 initialA;\n uint256 futureA;\n uint256 initialATime;\n uint256 futureATime;\n uint256 swapFee;\n uint256 adminFee;\n address lpToken;\n }\n\n /* Public Variables */\n\n /**\n * @notice Returns the index + 1 of the pool address in the registry\n * @param poolAddress address to look for\n */\n function poolsIndexOfPlusOne(address poolAddress)\n external\n returns (uint256);\n\n /**\n * @notice Returns the index + 1 of the pool name in the registry\n * @param poolName pool name in bytes32 format to look for\n */\n function poolsIndexOfNamePlusOne(bytes32 poolName)\n external\n returns (uint256);\n\n /* Functions */\n\n /**\n * @notice Add a new pool to the registry\n * @param inputData PoolInputData struct for the new pool\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\n * Only Swap and MetaSwap contracts need to be added.\n */\n function addPool(PoolInputData memory inputData) external payable;\n\n /**\n * @notice Add a new pool to the registry\n * @param data PoolInputData struct for the new pool\n * @dev Before adding a meta pool, the user must first add the underlying base pool.\n * Only Swap and MetaSwap contracts need to be added.\n */\n function addCommunityPool(PoolData memory data) external payable;\n\n /**\n * @notice Approve community deployed pools to be upgraded as Saddle owned\n * @dev since array entries are difficult to remove, we modify the entry to mark it\n * as a Saddle owned pool.\n * @param poolAddress address of the community pool\n */\n function approvePool(address poolAddress) external payable;\n\n /**\n * @notice Overwrite existing entry with new PoolData\n * @param poolData new PoolData struct to store\n */\n function updatePool(PoolData memory poolData) external payable;\n\n /**\n * @notice Remove pool from the registry\n * @dev Since arrays are not easily reducable, the entry will be marked as removed.\n * @param poolAddress address of the pool to remove\n */\n function removePool(address poolAddress) external payable;\n\n /**\n * @notice Returns PoolData for given pool address\n * @param poolAddress address of the pool to read\n */\n function getPoolData(address poolAddress)\n external\n view\n returns (PoolData memory);\n\n /**\n * @notice Returns PoolData at given index\n * @param index index of the pool to read\n */\n function getPoolDataAtIndex(uint256 index)\n external\n view\n returns (PoolData memory);\n\n /**\n * @notice Returns PoolData with given name\n * @param poolName name of the pool to read\n */\n function getPoolDataByName(bytes32 poolName)\n external\n view\n returns (PoolData memory);\n\n /**\n * @notice Returns virtual price of the given pool address\n * @param poolAddress address of the pool to read\n */\n function getVirtualPrice(address poolAddress)\n external\n view\n returns (uint256);\n\n /**\n * @notice Returns A of the given pool address\n * @param poolAddress address of the pool to read\n */\n function getA(address poolAddress) external view returns (uint256);\n\n /**\n * @notice Returns the paused status of the given pool address\n * @param poolAddress address of the pool to read\n */\n function getPaused(address poolAddress) external view returns (bool);\n\n /**\n * @notice Returns the SwapStorage struct of the given pool address\n * @param poolAddress address of the pool to read\n */\n function getSwapStorage(address poolAddress)\n external\n view\n returns (SwapStorageData memory swapStorageData);\n\n /**\n * @notice Returns the tokens of the given pool address\n * @param poolAddress address of the pool to read\n */\n function getTokens(address poolAddress)\n external\n view\n returns (IERC20[] memory);\n\n /**\n * @notice Returns the underlying tokens of the given pool address. Base pools will return an empty array.\n * @param poolAddress address of the pool to read\n */\n function getUnderlyingTokens(address poolAddress)\n external\n view\n returns (IERC20[] memory);\n\n /**\n * @notice Returns number of entries in the registry. Includes removed pools\n * in the list as well.\n */\n function getPoolsLength() external view returns (uint256);\n\n /**\n * @notice Returns an array of pool addresses that can swap between from and to\n * @param from address of the token to swap from\n * @param to address of the token to swap to\n * @return eligiblePools array of pool addresses that can swap between from and to\n */\n function getEligiblePools(address from, address to)\n external\n view\n returns (address[] memory eligiblePools);\n\n /**\n * @notice Returns an array of balances of the tokens\n * @param poolAddress address of the pool to look up the token balances for\n * @return balances array of token balances\n */\n function getTokenBalances(address poolAddress)\n external\n view\n returns (uint256[] memory balances);\n\n /**\n * @notice Returns an array of balances of the tokens\n * @param poolAddress address of the pool to look up the token balances for\n * @return balances array of token balances\n */\n function getUnderlyingTokenBalances(address poolAddress)\n external\n view\n returns (uint256[] memory balances);\n}\n" + }, + "contracts/interfaces/ISwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./IAllowlist.sol\";\n\ninterface ISwap {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getAPrecise() external view returns (uint256);\n\n function getAllowlist() external view returns (IAllowlist);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function owner() external view returns (address);\n\n function isGuarded() external view returns (bool);\n\n function paused() external view returns (bool);\n\n function swapStorage()\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256,\n uint256,\n uint256,\n address\n );\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function initialize(\n IERC20[] memory pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 a,\n uint256 fee,\n uint256 adminFee,\n address lpTokenTargetAddress\n ) external;\n\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n}\n" + }, + "contracts/interfaces/ISwapFlashLoan.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"./ISwap.sol\";\n\ninterface ISwapFlashLoan is ISwap {\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external;\n}\n" + }, + "contracts/interfaces/ISwapGuarded.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./IAllowlist.sol\";\n\ninterface ISwapGuarded {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getAllowlist() external view returns (IAllowlist);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function isGuarded() external view returns (bool);\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline,\n bytes32[] calldata merkleProof\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n\n // withdraw fee update function\n function updateUserWithdrawFee(address recipient, uint256 transferAmount)\n external;\n\n function swapStorage()\n external\n view\n returns (\n uint256 initialA,\n uint256 futureA,\n uint256 initialATime,\n uint256 futureATime,\n uint256 swapFee,\n uint256 adminFee,\n uint256 defaultWithdrawFee,\n address lpToken\n );\n}\n" + }, + "contracts/interfaces/ISwapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"./IAllowlist.sol\";\n\ninterface ISwapV1 {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getAllowlist() external view returns (IAllowlist);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function isGuarded() external view returns (bool);\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(\n address account,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256);\n\n function calculateRemoveLiquidity(address account, uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function initialize(\n IERC20[] memory pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 a,\n uint256 fee,\n uint256 adminFee,\n uint256 withdrawFee,\n address lpTokenTargetAddress\n ) external;\n\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n\n // withdraw fee update function\n function updateUserWithdrawFee(address recipient, uint256 transferAmount)\n external;\n}\n" + }, + "contracts/libraries/SwapCalculator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"../MathUtils.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../helper/BaseBoringBatchable.sol\";\n\ninterface IERC20Decimals {\n function decimals() external returns (uint8);\n}\n\n/**\n * @title SwapCalculator\n * @notice A contract to help calculate exact input and output amounts for a swap. Supports pools with ISwap interfaces.\n * Additionally includes functions to calculate with arbitrary balances, A parameter, and swap fee.\n */\ncontract SwapCalculator is BaseBoringBatchable {\n using SafeMath for uint256;\n using MathUtils for uint256;\n\n // Constant values\n uint256 private constant BALANCE_PRECISION = 1e18;\n uint256 private constant BALANCE_DECIMALS = 18;\n uint256 private constant A_PRECISION = 100;\n uint256 private constant MAX_LOOP_LIMIT = 256;\n uint256 private constant MAX_TOKENS_LENGTH = 8;\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n mapping(address => uint256[]) public storedDecimals;\n\n /**\n * @notice Calculate the expected output amount for given pool, indexes, and input amount\n * @param pool address of a pool contract that implements ISwap\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @param inputAmount amount of input token to swap\n * @return outputAmount expected output amount\n */\n function calculateSwapOutput(\n address pool,\n uint256 inputIndex,\n uint256 outputIndex,\n uint256 inputAmount\n ) external view returns (uint256 outputAmount) {\n outputAmount = ISwap(pool).calculateSwap(\n uint8(inputIndex),\n uint8(outputIndex),\n inputAmount\n );\n }\n\n /**\n * @notice Calculate the expected input amount for given pool, indexes, and out amount\n * @param pool address of a pool contract that implements ISwap\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @param outputAmount desired amount of output token to receive on swap\n * @return inputAmount expected input amount\n */\n function calculateSwapInput(\n address pool,\n uint256 inputIndex,\n uint256 outputIndex,\n uint256 outputAmount\n ) external view returns (uint256 inputAmount) {\n uint256[] memory decimalsArr = storedDecimals[pool];\n require(decimalsArr.length > 0, \"Must call addPool() first\");\n\n uint256[] memory balances = new uint256[](decimalsArr.length);\n for (uint256 i = 0; i < decimalsArr.length; i++) {\n uint256 multiplier = 10**BALANCE_DECIMALS.sub(decimalsArr[i]);\n balances[i] = ISwap(pool).getTokenBalance(uint8(i)).mul(multiplier);\n }\n outputAmount = outputAmount.mul(\n 10**BALANCE_DECIMALS.sub(decimalsArr[outputIndex])\n );\n\n (, , , , uint256 swapFee, , ) = ISwap(pool).swapStorage();\n\n inputAmount = calculateSwapInputCustom(\n balances,\n ISwap(pool).getAPrecise(),\n swapFee,\n inputIndex,\n outputIndex,\n outputAmount\n ).div(10**BALANCE_DECIMALS.sub(decimalsArr[inputIndex]));\n }\n\n /**\n * @notice Calculates the relative price between two assets in a pool\n * @param pool address of a pool contract that implements ISwap\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @return price relative price of output tokens per one input token\n */\n function relativePrice(\n address pool,\n uint256 inputIndex,\n uint256 outputIndex\n ) external view returns (uint256 price) {\n uint256[] memory decimalsArr = storedDecimals[pool];\n require(decimalsArr.length > 0, \"Must call addPool() first\");\n\n uint256[] memory balances = new uint256[](decimalsArr.length);\n for (uint256 i = 0; i < decimalsArr.length; i++) {\n uint256 multiplier = 10**BALANCE_DECIMALS.sub(decimalsArr[i]);\n balances[i] = ISwap(pool).getTokenBalance(uint8(i)).mul(multiplier);\n }\n\n price = relativePriceCustom(\n balances,\n ISwap(pool).getAPrecise(),\n inputIndex,\n outputIndex\n );\n }\n\n /**\n * @notice Calculate the expected input amount for given balances, A, swap fee, indexes, and out amount\n * @dev Uses 1e18 precision for balances, 1e2 for A, and 1e10 for swap fee\n * @param balances array of balances\n * @param a A parameter to be used in the calculation\n * @param swapFee fee to be charged per swap\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @param inputAmount amount of input token to swap\n * @return outputAmount expected output amount\n */\n function calculateSwapOutputCustom(\n uint256[] memory balances,\n uint256 a,\n uint256 swapFee,\n uint256 inputIndex,\n uint256 outputIndex,\n uint256 inputAmount\n ) public pure returns (uint256 outputAmount) {\n require(\n inputIndex < balances.length && outputIndex < balances.length,\n \"Invalid token index\"\n );\n // Calculate the swap\n uint256 x = inputAmount.add(balances[inputIndex]);\n uint256 y = getY(a, inputIndex, outputIndex, x, balances);\n outputAmount = balances[outputIndex].sub(y).sub(1);\n\n // Simulate the swap fee\n uint256 fee = outputAmount.mul(swapFee).div(FEE_DENOMINATOR);\n outputAmount = outputAmount.sub(fee);\n }\n\n /**\n * @notice Calculate the expected input amount for given balances, A, swap fee, indexes, and out amount\n * @dev Uses 1e18 precision for balances, 1e2 for A, and 1e10 for swap fee\n * @param balances array of balances\n * @param a A parameter to be used in the calculation\n * @param swapFee fee to be charged per swap\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @param outputAmount desired amount of output token to receive on swap\n * @return inputAmount expected input amount\n */\n function calculateSwapInputCustom(\n uint256[] memory balances,\n uint256 a,\n uint256 swapFee,\n uint256 inputIndex,\n uint256 outputIndex,\n uint256 outputAmount\n ) public pure returns (uint256 inputAmount) {\n require(\n inputIndex < balances.length && outputIndex < balances.length,\n \"Invalid token index\"\n );\n\n // Simulate the swap fee\n uint256 fee = outputAmount.mul(swapFee).div(\n FEE_DENOMINATOR.sub(swapFee)\n );\n outputAmount = outputAmount.add(fee);\n\n // Calculate the swap\n uint256 y = balances[outputIndex].sub(outputAmount);\n uint256 x = getX(a, inputIndex, outputIndex, y, balances);\n inputAmount = x.sub(balances[inputIndex]).add(1);\n }\n\n /**\n * @notice Calculate the relative price between two assets in given setup of balances and A\n * @dev Uses 1e18 precision for balances, 1e2 for A\n * @param balances array of balances\n * @param a A parameter to be used in the calculation\n * @param inputIndex index of the input token in the pool\n * @param outputIndex index of the output token in the pool\n * @return price relative price of output tokens per one input token\n */\n function relativePriceCustom(\n uint256[] memory balances,\n uint256 a,\n uint256 inputIndex,\n uint256 outputIndex\n ) public pure returns (uint256 price) {\n return\n calculateSwapOutputCustom(\n balances,\n a,\n 0,\n inputIndex,\n outputIndex,\n BALANCE_PRECISION\n );\n }\n\n /**\n * @notice Add and registers a new pool. This function exist to cache decimal information.\n * @param pool address of a pool contract that implements ISwap\n */\n function addPool(address pool) external payable {\n uint256[] memory decimalsArr = new uint256[](MAX_TOKENS_LENGTH);\n\n for (uint256 i = 0; i < MAX_TOKENS_LENGTH; i++) {\n try ISwap(pool).getToken(uint8(i)) returns (IERC20 token) {\n require(address(token) != address(0), \"Token invalid\");\n decimalsArr[i] = IERC20Decimals(address(token)).decimals();\n } catch {\n assembly {\n mstore(decimalsArr, sub(mload(decimalsArr), sub(8, i)))\n }\n break;\n }\n }\n\n require(decimalsArr.length > 0, \"Must call addPool() first\");\n storedDecimals[pool] = decimalsArr;\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\n * as the pool.\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\n * See the StableSwap paper for details\n * @return the invariant, at the precision of the pool\n */\n function getD(uint256[] memory xp, uint256 a)\n internal\n pure\n returns (uint256)\n {\n uint256 numTokens = xp.length;\n uint256 s;\n for (uint256 i = 0; i < numTokens; i++) {\n s = s.add(xp[i]);\n }\n if (s == 0) {\n return 0;\n }\n\n uint256 prevD;\n uint256 d = s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n uint256 dP = d;\n for (uint256 j = 0; j < numTokens; j++) {\n dP = dP.mul(d).div(xp[j].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // dP = dP * D * D * D * ... overflow!\n }\n prevD = d;\n d = nA.mul(s).div(A_PRECISION).add(dP.mul(numTokens)).mul(d).div(\n nA.sub(A_PRECISION).mul(d).div(A_PRECISION).add(\n numTokens.add(1).mul(dP)\n )\n );\n if (d.within1(prevD)) {\n return d;\n }\n }\n\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\n // function which does not rely on D.\n revert(\"D does not converge\");\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much TO token\n * the user should receive on swap.\n *\n * @param preciseA precise form of amplification coefficient\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param x the new total amount of FROM token\n * @param xp balances of the tokens in the pool\n * @return the amount of TO token that should remain in the pool\n */\n function getY(\n uint256 preciseA,\n uint256 tokenIndexFrom,\n uint256 tokenIndexTo,\n uint256 x,\n uint256[] memory xp\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(\n tokenIndexFrom != tokenIndexTo,\n \"Can't compare token to itself\"\n );\n require(\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\n \"Tokens must be in pool\"\n );\n\n uint256 d = getD(xp, preciseA);\n uint256 c = d;\n uint256 s;\n uint256 nA = numTokens.mul(preciseA);\n\n uint256 _x;\n for (uint256 i = 0; i < numTokens; i++) {\n if (i == tokenIndexFrom) {\n _x = x;\n } else if (i != tokenIndexTo) {\n _x = xp[i];\n } else {\n continue;\n }\n s = s.add(_x);\n c = c.mul(d).div(_x.mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n c = c.mul(d).mul(A_PRECISION).div(nA.mul(numTokens));\n uint256 b = s.add(d.mul(A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n\n // iterative approximation\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much FROM token\n * the user will be required to transfer on swap.\n *\n * @param preciseA precise form of amplification coefficient\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param y the new total amount of TO token\n * @param xp balances of the tokens in the pool\n * @return the amount of FROM token that will be required\n */\n function getX(\n uint256 preciseA,\n uint256 tokenIndexFrom,\n uint256 tokenIndexTo,\n uint256 y,\n uint256[] memory xp\n ) internal pure returns (uint256) {\n return getY(preciseA, tokenIndexTo, tokenIndexFrom, y, xp);\n }\n}\n" + }, + "contracts/LPToken.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./interfaces/ISwap.sol\";\n\n/**\n * @title Liquidity Provider Token\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\n * It is used to represent user's shares when providing liquidity to swap contracts.\n * @dev Only Swap contracts should initialize and own LPToken contracts.\n */\ncontract LPToken is ERC20BurnableUpgradeable, OwnableUpgradeable {\n using SafeMathUpgradeable for uint256;\n\n /**\n * @notice Initializes this LPToken contract with the given name and symbol\n * @dev The caller of this function will become the owner. A Swap contract should call this\n * in its initializer function.\n * @param name name of this token\n * @param symbol symbol of this token\n */\n function initialize(string memory name, string memory symbol)\n external\n initializer\n returns (bool)\n {\n __Context_init_unchained();\n __ERC20_init_unchained(name, symbol);\n __Ownable_init_unchained();\n return true;\n }\n\n /**\n * @notice Mints the given amount of LPToken to the recipient.\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n */\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(amount != 0, \"LPToken: cannot mint 0\");\n _mint(recipient, amount);\n }\n\n /**\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\n * This assumes the owner is set to a Swap contract's address.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20Upgradeable) {\n super._beforeTokenTransfer(from, to, amount);\n require(to != address(this), \"LPToken: cannot send to itself\");\n }\n}\n" + }, + "contracts/LPTokenV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./interfaces/ISwapV1.sol\";\n\n/**\n * @title Liquidity Provider Token\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\n * It is used to represent user's shares when providing liquidity to swap contracts.\n * @dev Only Swap contracts should initialize and own LPToken contracts.\n */\ncontract LPTokenV1 is ERC20BurnableUpgradeable, OwnableUpgradeable {\n using SafeMathUpgradeable for uint256;\n\n /**\n * @notice Initializes this LPToken contract with the given name and symbol\n * @dev The caller of this function will become the owner. A Swap contract should call this\n * in its initializer function.\n * @param name name of this token\n * @param symbol symbol of this token\n */\n function initialize(string memory name, string memory symbol)\n external\n initializer\n returns (bool)\n {\n __Context_init_unchained();\n __ERC20_init_unchained(name, symbol);\n __Ownable_init_unchained();\n return true;\n }\n\n /**\n * @notice Mints the given amount of LPToken to the recipient.\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n */\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(amount != 0, \"LPToken: cannot mint 0\");\n _mint(recipient, amount);\n }\n\n /**\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\n * This assumes the owner is set to a Swap contract's address.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20Upgradeable) {\n super._beforeTokenTransfer(from, to, amount);\n require(to != address(this), \"LPToken: cannot send to itself\");\n ISwapV1(owner()).updateUserWithdrawFee(to, amount);\n }\n}\n" + }, + "contracts/MathUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\n\n/**\n * @title MathUtils library\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\n * differences between two uint256.\n */\nlibrary MathUtils {\n /**\n * @notice Compares a and b and returns true if the difference between a and b\n * is less than 1 or equal to each other.\n * @param a uint256 to compare with\n * @param b uint256 to compare with\n * @return True if the difference between a and b is less than 1 or equal,\n * otherwise return false\n */\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\n return (difference(a, b) <= 1);\n }\n\n /**\n * @notice Calculates absolute difference between a and b\n * @param a uint256 to compare with\n * @param b uint256 to compare with\n * @return Difference between a and b\n */\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n }\n return b - a;\n }\n}\n" + }, + "contracts/meta/MetaSwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"../Swap.sol\";\nimport \"./MetaSwapUtils.sol\";\n\n/**\n * @title MetaSwap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\n *\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract MetaSwap is Swap {\n using MetaSwapUtils for SwapUtils.Swap;\n\n MetaSwapUtils.MetaSwap public metaSwapStorage;\n\n uint256 constant MAX_UINT256 = 2**256 - 1;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwapUnderlying(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice()\n external\n view\n virtual\n override\n returns (uint256)\n {\n return MetaSwapUtils.getVirtualPrice(swapStorage, metaSwapStorage);\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual override returns (uint256) {\n return\n MetaSwapUtils.calculateSwap(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx\n );\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap. For this function,\n * the token indices are flattened out so that underlying tokens are represented.\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual returns (uint256) {\n return\n MetaSwapUtils.calculateSwapUnderlying(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx\n );\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n virtual\n override\n returns (uint256)\n {\n return\n MetaSwapUtils.calculateTokenAmount(\n swapStorage,\n metaSwapStorage,\n amounts,\n deposit\n );\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view virtual override returns (uint256) {\n return\n MetaSwapUtils.calculateWithdrawOneToken(\n swapStorage,\n metaSwapStorage,\n tokenAmount,\n tokenIndex\n );\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice This overrides Swap's initialize function to prevent initializing\n * without the address of the base Swap contract.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual override initializer {\n revert(\"use initializeMetaSwap() instead\");\n }\n\n /**\n * @notice Initializes this MetaSwap contract with the given parameters.\n * MetaSwap uses an existing Swap pool to expand the available liquidity.\n * _pooledTokens array should contain the base Swap pool's LP token as\n * the last element. For example, if there is a Swap pool consisting of\n * [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken]\n * as _pooledTokens.\n *\n * This will also deploy the LPToken that represents users'\n * LP position. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint new tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept. The last\n * element must be an existing Swap pool's LP token's address.\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n */\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwap baseSwap\n ) public payable virtual initializer {\n Swap.initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n\n // MetaSwap initializer\n metaSwapStorage.baseSwap = baseSwap;\n metaSwapStorage.baseVirtualPrice = baseSwap.getVirtualPrice();\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\n\n // Read all tokens that belong to baseSwap\n {\n uint8 i;\n for (; i < 32; i++) {\n try baseSwap.getToken(i) returns (IERC20 token) {\n metaSwapStorage.baseTokens.push(token);\n token.safeApprove(address(baseSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"baseSwap must pool at least 2 tokens\");\n }\n\n // Check the last element of _pooledTokens is owned by baseSwap\n IERC20 baseLPToken = _pooledTokens[_pooledTokens.length - 1];\n require(\n LPToken(address(baseLPToken)).owner() == address(baseSwap),\n \"baseLPToken is not owned by baseSwap\"\n );\n\n // Pre-approve the baseLPToken to be used by baseSwap\n baseLPToken.safeApprove(address(baseSwap), MAX_UINT256);\n }\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtils.swap(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy\n );\n }\n\n /**\n * @notice Swap two tokens using this pool and the base pool.\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtils.swapUnderlying(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy\n );\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtils.addLiquidity(\n swapStorage,\n metaSwapStorage,\n amounts,\n minToMint\n );\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtils.removeLiquidityOneToken(\n swapStorage,\n metaSwapStorage,\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtils.removeLiquidityImbalance(\n swapStorage,\n metaSwapStorage,\n amounts,\n maxBurnAmount\n );\n }\n}\n" + }, + "contracts/meta/MetaSwapDeposit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\nimport \"../LPToken.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../interfaces/IMetaSwap.sol\";\n\n/**\n * @title MetaSwapDeposit\n * @notice This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be\n * deployed before this contract can be initialized successfully.\n *\n * For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT].\n * Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either\n * the LP token or the underlying tokens and sUSD.\n *\n * MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users\n * to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act\n * as a Swap containing [sUSD, DAI, USDC, USDT] tokens.\n */\ncontract MetaSwapDeposit is Initializable, ReentrancyGuardUpgradeable {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n ISwap public baseSwap;\n IMetaSwap public metaSwap;\n IERC20[] public baseTokens;\n IERC20[] public metaTokens;\n IERC20[] public tokens;\n IERC20 public metaLPToken;\n\n uint256 constant MAX_UINT256 = 2**256 - 1;\n\n struct RemoveLiquidityImbalanceInfo {\n ISwap baseSwap;\n IMetaSwap metaSwap;\n IERC20 metaLPToken;\n uint8 baseLPTokenIndex;\n bool withdrawFromBase;\n uint256 leftoverMetaLPTokenAmount;\n }\n\n /**\n * @notice Sets the address for the base Swap contract, MetaSwap contract, and the\n * MetaSwap LP token contract.\n * @param _baseSwap the address of the base Swap contract\n * @param _metaSwap the address of the MetaSwap contract\n * @param _metaLPToken the address of the MetaSwap LP token contract\n */\n function initialize(\n ISwap _baseSwap,\n IMetaSwap _metaSwap,\n IERC20 _metaLPToken\n ) external initializer {\n __ReentrancyGuard_init();\n // Check and approve base level tokens to be deposited to the base Swap contract\n {\n uint8 i;\n for (; i < 32; i++) {\n try _baseSwap.getToken(i) returns (IERC20 token) {\n baseTokens.push(token);\n token.safeApprove(address(_baseSwap), MAX_UINT256);\n token.safeApprove(address(_metaSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"baseSwap must have at least 2 tokens\");\n }\n\n // Check and approve meta level tokens to be deposited to the MetaSwap contract\n IERC20 baseLPToken;\n {\n uint8 i;\n for (; i < 32; i++) {\n try _metaSwap.getToken(i) returns (IERC20 token) {\n baseLPToken = token;\n metaTokens.push(token);\n tokens.push(token);\n token.safeApprove(address(_metaSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"metaSwap must have at least 2 tokens\");\n }\n\n // Flatten baseTokens and append it to tokens array\n tokens[tokens.length - 1] = baseTokens[0];\n for (uint8 i = 1; i < baseTokens.length; i++) {\n tokens.push(baseTokens[i]);\n }\n\n // Approve base Swap LP token to be burned by the base Swap contract for withdrawing\n baseLPToken.safeApprove(address(_baseSwap), MAX_UINT256);\n // Approve MetaSwap LP token to be burned by the MetaSwap contract for withdrawing\n _metaLPToken.safeApprove(address(_metaSwap), MAX_UINT256);\n\n // Initialize storage variables\n baseSwap = _baseSwap;\n metaSwap = _metaSwap;\n metaLPToken = _metaLPToken;\n }\n\n // Mutative functions\n\n /**\n * @notice Swap two underlying tokens using the meta pool and the base pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n tokens[tokenIndexFrom].safeTransferFrom(msg.sender, address(this), dx);\n uint256 tokenToAmount = metaSwap.swapUnderlying(\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy,\n deadline\n );\n tokens[tokenIndexTo].safeTransfer(msg.sender, tokenToAmount);\n return tokenToAmount;\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n // Read to memory to save on gas\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\n\n require(amounts.length == memBaseTokens.length + baseLPTokenIndex);\n\n uint256 baseLPTokenAmount;\n {\n // Transfer base tokens from the caller and deposit to the base Swap pool\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\n bool shouldDepositBaseTokens;\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\n IERC20 token = memBaseTokens[i];\n uint256 depositAmount = amounts[baseLPTokenIndex + i];\n if (depositAmount > 0) {\n token.safeTransferFrom(\n msg.sender,\n address(this),\n depositAmount\n );\n baseAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\n // if there are any base Swap level tokens, flag it for deposits\n shouldDepositBaseTokens = true;\n }\n }\n if (shouldDepositBaseTokens) {\n // Deposit any base Swap level tokens and receive baseLPToken\n baseLPTokenAmount = baseSwap.addLiquidity(\n baseAmounts,\n 0,\n deadline\n );\n }\n }\n\n uint256 metaLPTokenAmount;\n {\n // Transfer remaining meta level tokens from the caller\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n IERC20 token = memMetaTokens[i];\n uint256 depositAmount = amounts[i];\n if (depositAmount > 0) {\n token.safeTransferFrom(\n msg.sender,\n address(this),\n depositAmount\n );\n metaAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\n }\n }\n // Update the baseLPToken amount that will be deposited\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\n\n // Deposit the meta level tokens and the baseLPToken\n metaLPTokenAmount = metaSwap.addLiquidity(\n metaAmounts,\n minToMint,\n deadline\n );\n }\n\n // Transfer the meta lp token to the caller\n metaLPToken.safeTransfer(msg.sender, metaLPTokenAmount);\n\n return metaLPTokenAmount;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external nonReentrant returns (uint256[] memory) {\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256[] memory totalRemovedAmounts;\n\n {\n uint256 numOfAllTokens = memBaseTokens.length +\n memMetaTokens.length -\n 1;\n require(minAmounts.length == numOfAllTokens, \"out of range\");\n totalRemovedAmounts = new uint256[](numOfAllTokens);\n }\n\n // Transfer meta lp token from the caller to this\n metaLPToken.safeTransferFrom(msg.sender, address(this), amount);\n\n uint256 baseLPTokenAmount;\n {\n // Remove liquidity from the MetaSwap pool\n uint256[] memory removedAmounts;\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\n {\n uint256[] memory metaMinAmounts = new uint256[](\n memMetaTokens.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n metaMinAmounts[i] = minAmounts[i];\n }\n removedAmounts = metaSwap.removeLiquidity(\n amount,\n metaMinAmounts,\n deadline\n );\n }\n\n // Send the meta level tokens to the caller\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n totalRemovedAmounts[i] = removedAmounts[i];\n memMetaTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\n }\n baseLPTokenAmount = removedAmounts[baseLPTokenIndex];\n\n // Remove liquidity from the base Swap pool\n {\n uint256[] memory baseMinAmounts = new uint256[](\n memBaseTokens.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];\n }\n removedAmounts = baseSwap.removeLiquidity(\n baseLPTokenAmount,\n baseMinAmounts,\n deadline\n );\n }\n\n // Send the base level tokens to the caller\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\n totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i];\n memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\n }\n }\n\n return totalRemovedAmounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\n uint8 baseTokensLength = uint8(baseTokens.length);\n\n // Transfer metaLPToken from the caller\n metaLPToken.safeTransferFrom(msg.sender, address(this), tokenAmount);\n\n IERC20 token;\n if (tokenIndex < baseLPTokenIndex) {\n // When the desired token is meta level token, we can just call `removeLiquidityOneToken` directly\n metaSwap.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount,\n deadline\n );\n token = metaTokens[tokenIndex];\n } else if (tokenIndex < baseLPTokenIndex + baseTokensLength) {\n // When the desired token is a base level token, we need to first withdraw via baseLPToken, then withdraw\n // the desired token from the base Swap contract.\n uint256 removedBaseLPTokenAmount = metaSwap.removeLiquidityOneToken(\n tokenAmount,\n baseLPTokenIndex,\n 0,\n deadline\n );\n\n baseSwap.removeLiquidityOneToken(\n removedBaseLPTokenAmount,\n tokenIndex - baseLPTokenIndex,\n minAmount,\n deadline\n );\n token = baseTokens[tokenIndex - baseLPTokenIndex];\n } else {\n revert(\"out of range\");\n }\n\n uint256 amountWithdrawn = token.balanceOf(address(this));\n token.safeTransfer(msg.sender, amountWithdrawn);\n return amountWithdrawn;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256[] memory metaAmounts = new uint256[](memMetaTokens.length);\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\n\n require(\n amounts.length == memBaseTokens.length + memMetaTokens.length - 1,\n \"out of range\"\n );\n\n RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(\n baseSwap,\n metaSwap,\n metaLPToken,\n uint8(metaAmounts.length - 1),\n false,\n 0\n );\n\n for (uint8 i = 0; i < v.baseLPTokenIndex; i++) {\n metaAmounts[i] = amounts[i];\n }\n\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n baseAmounts[i] = amounts[v.baseLPTokenIndex + i];\n if (baseAmounts[i] > 0) {\n v.withdrawFromBase = true;\n }\n }\n\n // Calculate how much base LP token we need to get the desired amount of underlying tokens\n if (v.withdrawFromBase) {\n metaAmounts[v.baseLPTokenIndex] = v\n .baseSwap\n .calculateTokenAmount(baseAmounts, false)\n .mul(10005)\n .div(10000);\n }\n\n // Transfer MetaSwap LP token from the caller to this contract\n v.metaLPToken.safeTransferFrom(\n msg.sender,\n address(this),\n maxBurnAmount\n );\n\n // Withdraw the paired meta level tokens and the base LP token from the MetaSwap pool\n uint256 burnedMetaLPTokenAmount = v.metaSwap.removeLiquidityImbalance(\n metaAmounts,\n maxBurnAmount,\n deadline\n );\n v.leftoverMetaLPTokenAmount = maxBurnAmount.sub(\n burnedMetaLPTokenAmount\n );\n\n // If underlying tokens are desired, withdraw them from the base Swap pool\n if (v.withdrawFromBase) {\n v.baseSwap.removeLiquidityImbalance(\n baseAmounts,\n metaAmounts[v.baseLPTokenIndex],\n deadline\n );\n\n // Base Swap may require LESS base LP token than the amount we have\n // In that case, deposit it to the MetaSwap pool.\n uint256[] memory leftovers = new uint256[](metaAmounts.length);\n IERC20 baseLPToken = memMetaTokens[v.baseLPTokenIndex];\n uint256 leftoverBaseLPTokenAmount = baseLPToken.balanceOf(\n address(this)\n );\n if (leftoverBaseLPTokenAmount > 0) {\n leftovers[v.baseLPTokenIndex] = leftoverBaseLPTokenAmount;\n v.leftoverMetaLPTokenAmount = v.leftoverMetaLPTokenAmount.add(\n v.metaSwap.addLiquidity(leftovers, 0, deadline)\n );\n }\n }\n\n // Transfer all withdrawn tokens to the caller\n for (uint8 i = 0; i < amounts.length; i++) {\n IERC20 token;\n if (i < v.baseLPTokenIndex) {\n token = memMetaTokens[i];\n } else {\n token = memBaseTokens[i - v.baseLPTokenIndex];\n }\n if (amounts[i] > 0) {\n token.safeTransfer(msg.sender, amounts[i]);\n }\n }\n\n // If there were any extra meta lp token, transfer them back to the caller as well\n if (v.leftoverMetaLPTokenAmount > 0) {\n v.metaLPToken.safeTransfer(msg.sender, v.leftoverMetaLPTokenAmount);\n }\n\n return maxBurnAmount - v.leftoverMetaLPTokenAmount;\n }\n\n // VIEW FUNCTIONS\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running. When withdrawing from the base pool in imbalanced\n * fashion, the recommended slippage setting is 0.2% or higher.\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256)\n {\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\n uint256[] memory baseAmounts = new uint256[](baseTokens.length);\n uint256 baseLPTokenIndex = metaAmounts.length - 1;\n\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n metaAmounts[i] = amounts[i];\n }\n\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n baseAmounts[i] = amounts[baseLPTokenIndex + i];\n }\n\n uint256 baseLPTokenAmount = baseSwap.calculateTokenAmount(\n baseAmounts,\n deposit\n );\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\n\n return metaSwap.calculateTokenAmount(metaAmounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory)\n {\n uint256[] memory metaAmounts = metaSwap.calculateRemoveLiquidity(\n amount\n );\n uint8 baseLPTokenIndex = uint8(metaAmounts.length - 1);\n uint256[] memory baseAmounts = baseSwap.calculateRemoveLiquidity(\n metaAmounts[baseLPTokenIndex]\n );\n\n uint256[] memory totalAmounts = new uint256[](\n baseLPTokenIndex + baseAmounts.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n totalAmounts[i] = metaAmounts[i];\n }\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n totalAmounts[baseLPTokenIndex + i] = baseAmounts[i];\n }\n\n return totalAmounts;\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256) {\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\n\n if (tokenIndex < baseLPTokenIndex) {\n return\n metaSwap.calculateRemoveLiquidityOneToken(\n tokenAmount,\n tokenIndex\n );\n } else {\n uint256 baseLPTokenAmount = metaSwap\n .calculateRemoveLiquidityOneToken(\n tokenAmount,\n baseLPTokenIndex\n );\n return\n baseSwap.calculateRemoveLiquidityOneToken(\n baseLPTokenAmount,\n tokenIndex - baseLPTokenIndex\n );\n }\n }\n\n /**\n * @notice Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * This is a flattened representation of the pooled tokens.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) external view returns (IERC20) {\n require(index < tokens.length, \"index out of range\");\n return tokens[index];\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256) {\n return\n metaSwap.calculateSwapUnderlying(tokenIndexFrom, tokenIndexTo, dx);\n }\n}\n" + }, + "contracts/meta/MetaSwapUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"../LPToken.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../MathUtils.sol\";\nimport \"../SwapUtils.sol\";\n\n/**\n * @title MetaSwapUtils library\n * @notice A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n *\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary MetaSwapUtils {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using MathUtils for uint256;\n using AmplificationUtils for SwapUtils.Swap;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event TokenSwapUnderlying(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n\n struct MetaSwap {\n // Meta-Swap related parameters\n ISwap baseSwap;\n uint256 baseVirtualPrice;\n uint256 baseCacheLastUpdated;\n IERC20[] baseTokens;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n uint256 xpi;\n }\n\n // Struct storing variables used in calculation in removeLiquidityImbalance function\n // to avoid stack too deep error\n struct ManageLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n LPToken lpToken;\n uint256 totalSupply;\n uint256 preciseA;\n uint256 baseVirtualPrice;\n uint256[] tokenPrecisionMultipliers;\n uint256[] newBalances;\n }\n\n struct SwapUnderlyingInfo {\n uint256 x;\n uint256 dx;\n uint256 dy;\n uint256[] tokenPrecisionMultipliers;\n uint256[] oldBalances;\n IERC20[] baseTokens;\n IERC20 tokenFrom;\n uint8 metaIndexFrom;\n IERC20 tokenTo;\n uint8 metaIndexTo;\n uint256 baseVirtualPrice;\n }\n\n struct CalculateSwapUnderlyingInfo {\n uint256 baseVirtualPrice;\n ISwap baseSwap;\n uint8 baseLPTokenIndex;\n uint8 baseTokensLength;\n uint8 metaIndexTo;\n uint256 x;\n uint256 dy;\n }\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Cache expire time for the stored value of base Swap's virtual price\n uint256 public constant BASE_CACHE_EXPIRE_TIME = 10 minutes;\n uint256 public constant BASE_VIRTUAL_PRICE_PRECISION = 10**18;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n /**\n * @notice Return the stored value of base Swap's virtual price. If\n * value was updated past BASE_CACHE_EXPIRE_TIME, then read it directly\n * from the base Swap contract.\n * @param metaSwapStorage MetaSwap struct to read from\n * @return base Swap's virtual price\n */\n function _getBaseVirtualPrice(MetaSwap storage metaSwapStorage)\n internal\n view\n returns (uint256)\n {\n if (\n block.timestamp >\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\n ) {\n return metaSwapStorage.baseSwap.getVirtualPrice();\n }\n return metaSwapStorage.baseVirtualPrice;\n }\n\n function _getBaseSwapFee(ISwap baseSwap)\n internal\n view\n returns (uint256 swapFee)\n {\n (, , , , swapFee, , ) = baseSwap.swapStorage();\n }\n\n /**\n * @notice Calculate how much the user would receive when withdrawing via single token\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @return dy the amount of token user will receive\n */\n function calculateWithdrawOneToken(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n _getBaseVirtualPrice(metaSwapStorage),\n self.lpToken.totalSupply()\n );\n }\n\n function _calculateWithdrawOneToken(\n SwapUtils.Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 baseVirtualPrice,\n uint256 totalSupply\n ) internal view returns (uint256, uint256) {\n uint256 dy;\n uint256 dySwapFee;\n\n {\n uint256 currentY;\n uint256 newY;\n\n // Calculate how much to withdraw\n (dy, newY, currentY) = _calculateWithdrawOneTokenDY(\n self,\n tokenIndex,\n tokenAmount,\n baseVirtualPrice,\n totalSupply\n );\n\n // Calculate the associated swap fee\n dySwapFee = currentY\n .sub(newY)\n .div(self.tokenPrecisionMultipliers[tokenIndex])\n .sub(dy);\n }\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @param baseVirtualPrice the virtual price of the base swap's LP token\n * @return the dy excluding swap fee, the new y after withdrawing one token, and current y\n */\n function _calculateWithdrawOneTokenDY(\n SwapUtils.Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount,\n uint256 baseVirtualPrice,\n uint256 totalSupply\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self, baseVirtualPrice);\n require(tokenIndex < xp.length, \"Token index out of range\");\n\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(\n 0,\n 0,\n 0,\n 0,\n self._getAPrecise(),\n 0\n );\n v.d0 = SwapUtils.getD(xp, v.preciseA);\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = SwapUtils.getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = SwapUtils._feePerToken(self.swapFee, xp.length);\n for (uint256 i = 0; i < xp.length; i++) {\n v.xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] = v.xpi.sub(\n (\n (i == tokenIndex)\n ? v.xpi.mul(v.d1).div(v.d0).sub(v.newY)\n : v.xpi.sub(v.xpi.mul(v.d1).div(v.d0))\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\n );\n }\n\n uint256 dy = xpReduced[tokenIndex].sub(\n SwapUtils.getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\n );\n\n if (tokenIndex == xp.length.sub(1)) {\n dy = dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(baseVirtualPrice);\n v.newY = v.newY.mul(BASE_VIRTUAL_PRICE_PRECISION).div(\n baseVirtualPrice\n );\n xp[tokenIndex] = xp[tokenIndex]\n .mul(BASE_VIRTUAL_PRICE_PRECISION)\n .div(baseVirtualPrice);\n }\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\n\n return (dy, v.newY, xp[tokenIndex]);\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances. The last element will also get scaled up by\n * the given baseVirtualPrice.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @param baseVirtualPrice the base virtual price to scale the balance of the\n * base Swap's LP token.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers,\n uint256 baseVirtualPrice\n ) internal pure returns (uint256[] memory) {\n uint256[] memory xp = SwapUtils._xp(balances, precisionMultipliers);\n uint256 baseLPTokenIndex = balances.length.sub(1);\n xp[baseLPTokenIndex] = xp[baseLPTokenIndex].mul(baseVirtualPrice).div(\n BASE_VIRTUAL_PRICE_PRECISION\n );\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(SwapUtils.Swap storage self, uint256 baseVirtualPrice)\n internal\n view\n returns (uint256[] memory)\n {\n return\n _xp(\n self.balances,\n self.tokenPrecisionMultipliers,\n baseVirtualPrice\n );\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @return the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION\n */\n function getVirtualPrice(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage\n ) external view returns (uint256) {\n uint256 d = SwapUtils.getD(\n _xp(\n self.balances,\n self.tokenPrecisionMultipliers,\n _getBaseVirtualPrice(metaSwapStorage)\n ),\n self._getAPrecise()\n );\n uint256 supply = self.lpToken.totalSupply();\n if (supply != 0) {\n return d.mul(BASE_VIRTUAL_PRICE_PRECISION).div(supply);\n }\n return 0;\n }\n\n /**\n * @notice Externally calculates a swap between two tokens. The SwapUtils.Swap storage and\n * MetaSwap storage should be from the same MetaSwap contract.\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct from the same contract\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n _getBaseVirtualPrice(metaSwapStorage)\n );\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param baseVirtualPrice the virtual price of the base LP token\n * @return dy the number of tokens the user will get and dyFee the associated fee\n */\n function _calculateSwap(\n SwapUtils.Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 baseVirtualPrice\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory xp = _xp(self, baseVirtualPrice);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 baseLPTokenIndex = xp.length.sub(1);\n\n uint256 x = dx.mul(self.tokenPrecisionMultipliers[tokenIndexFrom]);\n if (tokenIndexFrom == baseLPTokenIndex) {\n // When swapping from a base Swap token, scale up dx by its virtual price\n x = x.mul(baseVirtualPrice).div(BASE_VIRTUAL_PRICE_PRECISION);\n }\n x = x.add(xp[tokenIndexFrom]);\n\n uint256 y = SwapUtils.getY(\n self._getAPrecise(),\n tokenIndexFrom,\n tokenIndexTo,\n x,\n xp\n );\n dy = xp[tokenIndexTo].sub(y).sub(1);\n\n if (tokenIndexTo == baseLPTokenIndex) {\n // When swapping to a base Swap token, scale down dy by its virtual price\n dy = dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(baseVirtualPrice);\n }\n\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n dy = dy.sub(dyFee);\n\n dy = dy.div(self.tokenPrecisionMultipliers[tokenIndexTo]);\n }\n\n /**\n * @notice Calculates the expected return amount from swapping between\n * the pooled tokens and the underlying tokens of the base Swap pool.\n *\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct from the same contract\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwapUnderlying(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256) {\n CalculateSwapUnderlyingInfo memory v = CalculateSwapUnderlyingInfo(\n _getBaseVirtualPrice(metaSwapStorage),\n metaSwapStorage.baseSwap,\n 0,\n uint8(metaSwapStorage.baseTokens.length),\n 0,\n 0,\n 0\n );\n\n uint256[] memory xp = _xp(self, v.baseVirtualPrice);\n v.baseLPTokenIndex = uint8(xp.length.sub(1));\n {\n uint8 maxRange = v.baseLPTokenIndex + v.baseTokensLength;\n require(\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\n \"Token index out of range\"\n );\n }\n\n if (tokenIndexFrom < v.baseLPTokenIndex) {\n // tokenFrom is from this pool\n v.x = xp[tokenIndexFrom].add(\n dx.mul(self.tokenPrecisionMultipliers[tokenIndexFrom])\n );\n } else {\n // tokenFrom is from the base pool\n tokenIndexFrom = tokenIndexFrom - v.baseLPTokenIndex;\n if (tokenIndexTo < v.baseLPTokenIndex) {\n uint256[] memory baseInputs = new uint256[](v.baseTokensLength);\n baseInputs[tokenIndexFrom] = dx;\n v.x = v\n .baseSwap\n .calculateTokenAmount(baseInputs, true)\n .mul(v.baseVirtualPrice)\n .div(BASE_VIRTUAL_PRICE_PRECISION);\n // when adding to the base pool,you pay approx 50% of the swap fee\n v.x = v\n .x\n .sub(\n v.x.mul(_getBaseSwapFee(metaSwapStorage.baseSwap)).div(\n FEE_DENOMINATOR.mul(2)\n )\n )\n .add(xp[v.baseLPTokenIndex]);\n } else {\n // both from and to are from the base pool\n return\n v.baseSwap.calculateSwap(\n tokenIndexFrom,\n tokenIndexTo - v.baseLPTokenIndex,\n dx\n );\n }\n tokenIndexFrom = v.baseLPTokenIndex;\n }\n\n v.metaIndexTo = v.baseLPTokenIndex;\n if (tokenIndexTo < v.baseLPTokenIndex) {\n v.metaIndexTo = tokenIndexTo;\n }\n\n {\n uint256 y = SwapUtils.getY(\n self._getAPrecise(),\n tokenIndexFrom,\n v.metaIndexTo,\n v.x,\n xp\n );\n v.dy = xp[v.metaIndexTo].sub(y).sub(1);\n uint256 dyFee = v.dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n v.dy = v.dy.sub(dyFee);\n }\n\n if (tokenIndexTo < v.baseLPTokenIndex) {\n // tokenTo is from this pool\n v.dy = v.dy.div(self.tokenPrecisionMultipliers[v.metaIndexTo]);\n } else {\n // tokenTo is from the base pool\n v.dy = v.baseSwap.calculateRemoveLiquidityOneToken(\n v.dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(v.baseVirtualPrice),\n tokenIndexTo - v.baseLPTokenIndex\n );\n }\n\n return v.dy;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 a = self._getAPrecise();\n uint256 d0;\n uint256 d1;\n {\n uint256 baseVirtualPrice = _getBaseVirtualPrice(metaSwapStorage);\n uint256[] memory balances1 = self.balances;\n uint256[] memory tokenPrecisionMultipliers = self\n .tokenPrecisionMultipliers;\n uint256 numTokens = balances1.length;\n d0 = SwapUtils.getD(\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\n a\n );\n for (uint256 i = 0; i < numTokens; i++) {\n if (deposit) {\n balances1[i] = balances1[i].add(amounts[i]);\n } else {\n balances1[i] = balances1[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n }\n d1 = SwapUtils.getD(\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\n a\n );\n }\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return d1.sub(d0).mul(totalSupply).div(d0);\n } else {\n return d0.sub(d1).mul(totalSupply).div(d0);\n }\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n {\n uint256 pooledTokensLength = self.pooledTokens.length;\n require(\n tokenIndexFrom < pooledTokensLength &&\n tokenIndexTo < pooledTokensLength,\n \"Token index is out of range\"\n );\n }\n\n uint256 transferredDx;\n {\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\n require(\n dx <= tokenFrom.balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n\n {\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n\n // Use the actual transferred amount for AMM math\n transferredDx = tokenFrom.balanceOf(address(this)).sub(\n beforeBalance\n );\n }\n }\n\n (uint256 dy, uint256 dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n transferredDx,\n _updateBaseVirtualPrice(metaSwapStorage)\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\n self.tokenPrecisionMultipliers[tokenIndexTo]\n );\n\n self.balances[tokenIndexFrom] = self.balances[tokenIndexFrom].add(\n transferredDx\n );\n self.balances[tokenIndexTo] = self.balances[tokenIndexTo].sub(dy).sub(\n dyAdminFee\n );\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(\n msg.sender,\n transferredDx,\n dy,\n tokenIndexFrom,\n tokenIndexTo\n );\n\n return dy;\n }\n\n /**\n * @notice Swaps with the underlying tokens of the base Swap pool. For this function,\n * the token indices are flattened out so that underlying tokens are represented\n * in the indices.\n * @dev Since this calls multiple external functions during the execution,\n * it is recommended to protect any function that depends on this with reentrancy guards.\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swapUnderlying(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n SwapUnderlyingInfo memory v = SwapUnderlyingInfo(\n 0,\n 0,\n 0,\n self.tokenPrecisionMultipliers,\n self.balances,\n metaSwapStorage.baseTokens,\n IERC20(address(0)),\n 0,\n IERC20(address(0)),\n 0,\n _updateBaseVirtualPrice(metaSwapStorage)\n );\n\n uint8 baseLPTokenIndex = uint8(v.oldBalances.length.sub(1));\n\n {\n uint8 maxRange = uint8(baseLPTokenIndex + v.baseTokens.length);\n require(\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\n \"Token index out of range\"\n );\n }\n\n ISwap baseSwap = metaSwapStorage.baseSwap;\n\n // Find the address of the token swapping from and the index in MetaSwap's token list\n if (tokenIndexFrom < baseLPTokenIndex) {\n v.tokenFrom = self.pooledTokens[tokenIndexFrom];\n v.metaIndexFrom = tokenIndexFrom;\n } else {\n v.tokenFrom = v.baseTokens[tokenIndexFrom - baseLPTokenIndex];\n v.metaIndexFrom = baseLPTokenIndex;\n }\n\n // Find the address of the token swapping to and the index in MetaSwap's token list\n if (tokenIndexTo < baseLPTokenIndex) {\n v.tokenTo = self.pooledTokens[tokenIndexTo];\n v.metaIndexTo = tokenIndexTo;\n } else {\n v.tokenTo = v.baseTokens[tokenIndexTo - baseLPTokenIndex];\n v.metaIndexTo = baseLPTokenIndex;\n }\n\n // Check for possible fee on transfer\n v.dx = v.tokenFrom.balanceOf(address(this));\n v.tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n v.dx = v.tokenFrom.balanceOf(address(this)).sub(v.dx); // update dx in case of fee on transfer\n\n if (\n tokenIndexFrom < baseLPTokenIndex || tokenIndexTo < baseLPTokenIndex\n ) {\n // Either one of the tokens belongs to the MetaSwap tokens list\n uint256[] memory xp = _xp(\n v.oldBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n );\n\n if (tokenIndexFrom < baseLPTokenIndex) {\n // Swapping from a MetaSwap token\n v.x = xp[tokenIndexFrom].add(\n dx.mul(v.tokenPrecisionMultipliers[tokenIndexFrom])\n );\n } else {\n // Swapping from one of the tokens hosted in the base Swap\n // This case requires adding the underlying token to the base Swap, then\n // using the base LP token to swap to the desired token\n uint256[] memory baseAmounts = new uint256[](\n v.baseTokens.length\n );\n baseAmounts[tokenIndexFrom - baseLPTokenIndex] = v.dx;\n\n // Add liquidity to the base Swap contract and receive base LP token\n v.dx = baseSwap.addLiquidity(baseAmounts, 0, block.timestamp);\n\n // Calculate the value of total amount of baseLPToken we end up with\n v.x = v\n .dx\n .mul(v.baseVirtualPrice)\n .div(BASE_VIRTUAL_PRICE_PRECISION)\n .add(xp[baseLPTokenIndex]);\n }\n\n // Calculate how much to withdraw in MetaSwap level and the the associated swap fee\n uint256 dyFee;\n {\n uint256 y = SwapUtils.getY(\n self._getAPrecise(),\n v.metaIndexFrom,\n v.metaIndexTo,\n v.x,\n xp\n );\n v.dy = xp[v.metaIndexTo].sub(y).sub(1);\n if (tokenIndexTo >= baseLPTokenIndex) {\n // When swapping to a base Swap token, scale down dy by its virtual price\n v.dy = v.dy.mul(BASE_VIRTUAL_PRICE_PRECISION).div(\n v.baseVirtualPrice\n );\n }\n dyFee = v.dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n v.dy = v.dy.sub(dyFee).div(\n v.tokenPrecisionMultipliers[v.metaIndexTo]\n );\n }\n\n // Update the balances array according to the calculated input and output amount\n {\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(\n FEE_DENOMINATOR\n );\n dyAdminFee = dyAdminFee.div(\n v.tokenPrecisionMultipliers[v.metaIndexTo]\n );\n self.balances[v.metaIndexFrom] = v\n .oldBalances[v.metaIndexFrom]\n .add(v.dx);\n self.balances[v.metaIndexTo] = v\n .oldBalances[v.metaIndexTo]\n .sub(v.dy)\n .sub(dyAdminFee);\n }\n\n if (tokenIndexTo >= baseLPTokenIndex) {\n // When swapping to a token that belongs to the base Swap, burn the LP token\n // and withdraw the desired token from the base pool\n uint256 oldBalance = v.tokenTo.balanceOf(address(this));\n baseSwap.removeLiquidityOneToken(\n v.dy,\n tokenIndexTo - baseLPTokenIndex,\n 0,\n block.timestamp\n );\n v.dy = v.tokenTo.balanceOf(address(this)) - oldBalance;\n }\n\n // Check the amount of token to send meets minDy\n require(v.dy >= minDy, \"Swap didn't result in min tokens\");\n } else {\n // Both tokens are from the base Swap pool\n // Do a swap through the base Swap\n v.dy = v.tokenTo.balanceOf(address(this));\n baseSwap.swap(\n tokenIndexFrom - baseLPTokenIndex,\n tokenIndexTo - baseLPTokenIndex,\n v.dx,\n minDy,\n block.timestamp\n );\n v.dy = v.tokenTo.balanceOf(address(this)).sub(v.dy);\n }\n\n // Send the desired token to the caller\n v.tokenTo.safeTransfer(msg.sender, v.dy);\n\n emit TokenSwapUnderlying(\n msg.sender,\n dx,\n v.dy,\n tokenIndexFrom,\n tokenIndexTo\n );\n\n return v.dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] memory amounts,\n uint256 minToMint\n ) external returns (uint256) {\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(\n amounts.length == pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n uint256[] memory fees = new uint256[](pooledTokens.length);\n\n // current state\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n self.lpToken,\n 0,\n self._getAPrecise(),\n _updateBaseVirtualPrice(metaSwapStorage),\n self.tokenPrecisionMultipliers,\n self.balances\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n if (v.totalSupply != 0) {\n v.d0 = SwapUtils.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n }\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n require(\n v.totalSupply != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = pooledTokens[i].balanceOf(\n address(this)\n );\n pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\n beforeBalance\n );\n }\n\n v.newBalances[i] = v.newBalances[i].add(amounts[i]);\n }\n\n // invariant after change\n v.d1 = SwapUtils.getD(\n _xp(v.newBalances, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n require(v.d1 > v.d0, \"D should increase\");\n\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n uint256 toMint;\n\n if (v.totalSupply != 0) {\n uint256 feePerToken = SwapUtils._feePerToken(\n self.swapFee,\n pooledTokens.length\n );\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(self.balances[i]).div(v.d0);\n fees[i] = feePerToken\n .mul(idealBalance.difference(v.newBalances[i]))\n .div(FEE_DENOMINATOR);\n self.balances[i] = v.newBalances[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n v.newBalances[i] = v.newBalances[i].sub(fees[i]);\n }\n v.d2 = SwapUtils.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\n } else {\n // the initial depositor doesn't pay fees\n self.balances = v.newBalances;\n toMint = v.d1;\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n self.lpToken.mint(msg.sender, toMint);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.add(toMint)\n );\n\n return toMint;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n LPToken lpToken = self.lpToken;\n uint256 totalSupply = lpToken.totalSupply();\n uint256 numTokens = self.pooledTokens.length;\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 dyFee;\n uint256 dy;\n\n (dy, dyFee) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n _updateBaseVirtualPrice(metaSwapStorage),\n totalSupply\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n // Update balances array\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\n );\n\n // Burn the associated LP token from the caller and send the desired token\n lpToken.burnFrom(msg.sender, tokenAmount);\n self.pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n SwapUtils.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n // Using this struct to avoid stack too deep error\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n self.lpToken,\n 0,\n self._getAPrecise(),\n _updateBaseVirtualPrice(metaSwapStorage),\n self.tokenPrecisionMultipliers,\n self.balances\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n require(\n amounts.length == v.newBalances.length,\n \"Amounts should match pool tokens\"\n );\n require(maxBurnAmount != 0, \"Must burn more than 0\");\n\n uint256 feePerToken = SwapUtils._feePerToken(\n self.swapFee,\n v.newBalances.length\n );\n\n // Calculate how much LPToken should be burned\n uint256[] memory fees = new uint256[](v.newBalances.length);\n {\n uint256[] memory balances1 = new uint256[](v.newBalances.length);\n\n v.d0 = SwapUtils.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n balances1[i] = v.newBalances[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n v.d1 = SwapUtils.getD(\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n uint256 idealBalance = v.d1.mul(v.newBalances[i]).div(v.d0);\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\n self.balances[i] = balances1[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n balances1[i] = balances1[i].sub(fees[i]);\n }\n\n v.d2 = SwapUtils.getD(\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n }\n\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n\n // Scale up by withdraw fee\n tokenAmount = tokenAmount.add(1);\n\n // Check for max burn amount\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n // Burn the calculated amount of LPToken from the caller and send the desired tokens\n v.lpToken.burnFrom(msg.sender, tokenAmount);\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.sub(tokenAmount)\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice Determines if the stored value of base Swap's virtual price is expired.\n * If the last update was past the BASE_CACHE_EXPIRE_TIME, then update the stored value.\n *\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @return base Swap's virtual price\n */\n function _updateBaseVirtualPrice(MetaSwap storage metaSwapStorage)\n internal\n returns (uint256)\n {\n if (\n block.timestamp >\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\n ) {\n // When the cache is expired, update it\n uint256 baseVirtualPrice = ISwap(metaSwapStorage.baseSwap)\n .getVirtualPrice();\n metaSwapStorage.baseVirtualPrice = baseVirtualPrice;\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\n return baseVirtualPrice;\n } else {\n return metaSwapStorage.baseVirtualPrice;\n }\n }\n}\n" + }, + "contracts/OwnerPausableUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol\";\n\n/**\n * @title OwnerPausable\n * @notice An ownable contract allows the owner to pause and unpause the\n * contract without a delay.\n * @dev Only methods using the provided modifiers will be paused.\n */\nabstract contract OwnerPausableUpgradeable is\n OwnableUpgradeable,\n PausableUpgradeable\n{\n function __OwnerPausable_init() internal initializer {\n __Context_init_unchained();\n __Ownable_init_unchained();\n __Pausable_init_unchained();\n }\n\n /**\n * @notice Pause the contract. Revert if already paused.\n */\n function pause() external onlyOwner {\n PausableUpgradeable._pause();\n }\n\n /**\n * @notice Unpause the contract. Revert if already unpaused.\n */\n function unpause() external onlyOwner {\n PausableUpgradeable._unpause();\n }\n}\n" + }, + "contracts/permissionless/FlashLoanEnabled.sol": { + "content": "// SPDX-License-Identifier: MIT WITH AGPL-3.0-only\n\npragma solidity 0.6.12;\n\nimport \"./PermissionlessSwap.sol\";\nimport \"../interfaces/IFlashLoanReceiver.sol\";\n\nabstract contract FlashLoanEnabled {\n // Total fee that is charged on all flashloans in BPS. Borrowers must repay the amount plus the flash loan fee.\n // This fee is split between the protocol and the pool.\n uint256 public flashLoanFeeBPS;\n // Share of the flash loan fee that goes to the protocol in BPS. A portion of each flash loan fee is allocated\n // to the protocol rather than the pool.\n uint256 public protocolFeeShareBPS;\n // Max BPS for limiting flash loan fee settings.\n uint256 public constant MAX_BPS = 10000;\n\n /*** EVENTS ***/\n event FlashLoan(\n address indexed receiver,\n uint8 tokenIndex,\n uint256 amount,\n uint256 amountFee,\n uint256 protocolFee\n );\n\n /**\n * @notice Borrow the specified token from this pool for this transaction only. This function will call\n * `IFlashLoanReceiver(receiver).executeOperation` and the `receiver` must return the full amount of the token\n * and the associated fee by the end of the callback transaction. If the conditions are not met, this call\n * is reverted.\n * @param receiver the address of the receiver of the token. This address must implement the IFlashLoanReceiver\n * interface and the callback function `executeOperation`.\n * @param token the protocol fee in bps to be applied on the total flash loan fee\n * @param amount the total amount to borrow in this transaction\n * @param params optional data to pass along to the callback function\n */\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external payable virtual;\n\n /**\n * @notice Updates the flash loan fee parameters.\n * @dev This function should be overridden for permissions.\n * @param newFlashLoanFeeBPS the total fee in bps to be applied on future flash loans\n * @param newProtocolFeeShareBPS the protocol fee in bps to be applied on the total flash loan fee\n */\n function _setFlashLoanFees(\n uint256 newFlashLoanFeeBPS,\n uint256 newProtocolFeeShareBPS\n ) internal {\n require(\n newFlashLoanFeeBPS > 0 &&\n newFlashLoanFeeBPS <= MAX_BPS &&\n newProtocolFeeShareBPS <= MAX_BPS,\n \"fees are not in valid range\"\n );\n flashLoanFeeBPS = newFlashLoanFeeBPS;\n protocolFeeShareBPS = newProtocolFeeShareBPS;\n }\n}\n" + }, + "contracts/permissionless/PermissionlessDeployer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../interfaces/IMetaSwap.sol\";\nimport \"../interfaces/IMetaSwapDeposit.sol\";\nimport \"../interfaces/IPoolRegistry.sol\";\nimport \"../interfaces/IMasterRegistry.sol\";\n\n/**\n * @title PermissionlessDeployer\n * @notice Allows for anyone to indepentantly deploy pools and meta pools of given tokens. A user will set\n * custom parameters for the pool such as the trading/admin fees, as well as the a-parameter.\n *\n * Ownership of the pools are given to the deploying address. Saddle will collect 50% of the trading fees earned\n * by the pool.\n */\ncontract PermissionlessDeployer is AccessControl {\n IMasterRegistry public immutable MASTER_REGISTRY;\n bytes32 public constant POOL_REGISTRY_NAME =\n 0x506f6f6c52656769737472790000000000000000000000000000000000000000;\n\n /// @notice Role responsible for managing target addresses\n bytes32 public constant SADDLE_MANAGER_ROLE =\n keccak256(\"SADDLE_MANAGER_ROLE\");\n\n address public targetLPToken;\n address public targetSwap;\n address public targetMetaSwap;\n address public targetMetaSwapDeposit;\n string public constant LP_TOKEN_NAME0 = \"Saddle \";\n string public constant LP_TOKEN_NAME1 = \" LP Token\";\n\n IPoolRegistry public poolRegistryCached;\n\n /**\n * @notice Emmited when a new pool is deployed\n * @param deployer address of the deployer\n * @param swapAddress address of the deployed pool\n * @param pooledTokens, array of addresses of the tokens in the pool\n */\n event NewSwapPool(\n address indexed deployer,\n address swapAddress,\n IERC20[] pooledTokens\n );\n\n event NewClone(address indexed target, address cloneAddress);\n\n /**\n * @notice Emmited when the pool registry cache is updated\n * @param poolRegistry address of the current Saddle Pool Registry\n */\n event PoolRegistryUpdated(address indexed poolRegistry);\n event TargetLPTokenUpdated(address indexed target);\n event TargetSwapUpdated(address indexed target);\n event TargetMetaSwapUpdated(address indexed target);\n event TargetMetaSwapDepositUpdated(address indexed target);\n\n struct DeploySwapInput {\n bytes32 poolName; // name of the pool\n IERC20[] tokens; // array of addresses of the tokens in the pool\n uint8[] decimals; // array of decimals of the tokens in the pool\n string lpTokenSymbol; // symbol of the LPToken\n uint256 a; // a-parameter of the pool\n uint256 fee; // trading fee of the pool\n uint256 adminFee; // admin fee of the pool\n address owner; // owner address of the pool\n uint8 typeOfAsset; // USD/BTC/ETH/OTHER\n }\n\n struct DeployMetaSwapInput {\n bytes32 poolName; // name of the pool\n IERC20[] tokens; // array of addresses of the tokens in the pool\n uint8[] decimals; // array of decimals of the tokens in the pool\n string lpTokenSymbol; // symbol of the LPToken\n uint256 a; // a-parameter of the pool\n uint256 fee; // trading fee of the pool\n uint256 adminFee; // admin fee of the pool\n address baseSwap; // address of the basepool\n address owner; // owner address of the pool\n uint8 typeOfAsset; // USD/BTC/ETH/OTHER\n }\n\n constructor(\n address admin,\n address _masterRegistry,\n address _targetLPToken,\n address _targetSwap,\n address _targetMetaSwap,\n address _targetMetaSwapDeposit\n ) public payable {\n require(admin != address(0), \"admin == 0\");\n require(_masterRegistry != address(0), \"masterRegistry == 0\");\n\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\n\n _setTargetLPToken(_targetLPToken);\n _setTargetSwap(_targetSwap);\n _setTargetMetaSwap(_targetMetaSwap);\n _setTargetMetaSwapDeposit(_targetMetaSwapDeposit);\n\n MASTER_REGISTRY = IMasterRegistry(_masterRegistry);\n _updatePoolRegistryCache(_masterRegistry);\n }\n\n modifier onlyManager() {\n require(hasRole(SADDLE_MANAGER_ROLE, msg.sender), \"only manager\");\n _;\n }\n\n /**\n * @notice Uses openzeppelin's clone mechanism to clone an existing a pool for cheaper deployments.\n * @param target the address of the target pool to be cloned\n * @return newClone an address of the cloned pool\n */\n function clone(address target) public payable returns (address newClone) {\n newClone = Clones.clone(target);\n emit NewClone(target, newClone);\n }\n\n /**\n * @notice Deploys a new pool, adds an entry in the Saddle Pool Registry.\n * @param input, a struct containing the input parameters for the pool to be deployed,\n * must include a unique pool name.\n * @return deployedSwap the address of the deployed pool.\n */\n\n function deploySwap(DeploySwapInput memory input)\n external\n payable\n returns (address deployedSwap)\n {\n require(\n poolRegistryCached.poolsIndexOfNamePlusOne(input.poolName) == 0,\n \"pool name already exists\"\n );\n\n address swapClone = clone(targetSwap);\n\n ISwap(swapClone).initialize(\n input.tokens,\n input.decimals,\n string(\n abi.encodePacked(\n LP_TOKEN_NAME0,\n input.lpTokenSymbol,\n LP_TOKEN_NAME1\n )\n ),\n input.lpTokenSymbol,\n input.a,\n input.fee,\n input.adminFee,\n targetLPToken\n );\n Ownable(swapClone).transferOwnership(input.owner);\n (, , , , , , address lpToken) = ISwap(swapClone).swapStorage();\n\n IPoolRegistry.PoolData memory poolData = IPoolRegistry.PoolData({\n poolAddress: swapClone,\n lpToken: lpToken,\n typeOfAsset: input.typeOfAsset,\n poolName: input.poolName,\n targetAddress: targetSwap,\n tokens: input.tokens,\n underlyingTokens: new IERC20[](0),\n basePoolAddress: address(0),\n metaSwapDepositAddress: address(0),\n isSaddleApproved: false,\n isRemoved: false,\n isGuarded: false\n });\n\n emit NewSwapPool(msg.sender, swapClone, input.tokens);\n\n poolRegistryCached.addCommunityPool(poolData);\n return swapClone;\n }\n\n /**\n * @notice Deploys a new meta pool.\n * @param input, a DeployMetaSwapInput struct containing the input parameters for the meta pool.\n */\n function deployMetaSwap(DeployMetaSwapInput memory input)\n external\n payable\n returns (address deployedMetaSwap, address deployedMetaSwapDeposit)\n {\n require(\n poolRegistryCached.poolsIndexOfNamePlusOne(input.poolName) == 0,\n \"pool name already exists\"\n );\n\n deployedMetaSwap = clone(targetMetaSwap);\n IMetaSwap(deployedMetaSwap).initializeMetaSwap(\n input.tokens,\n input.decimals,\n string(\n abi.encodePacked(\n LP_TOKEN_NAME0,\n input.lpTokenSymbol,\n LP_TOKEN_NAME1\n )\n ),\n input.lpTokenSymbol,\n input.a,\n input.fee,\n input.adminFee,\n targetLPToken,\n ISwap(input.baseSwap)\n );\n (, , , , , , address lpToken) = ISwap(deployedMetaSwap).swapStorage();\n Ownable(deployedMetaSwap).transferOwnership(input.owner);\n\n deployedMetaSwapDeposit = clone(targetMetaSwapDeposit);\n IMetaSwapDeposit(deployedMetaSwapDeposit).initialize(\n ISwap(input.baseSwap),\n IMetaSwap(deployedMetaSwap),\n IERC20(lpToken)\n );\n\n IERC20[] memory baseTokens = poolRegistryCached.getTokens(\n input.baseSwap\n ); // revert if baseSwap is not registered\n IERC20[] memory underlyingTokens = new IERC20[](\n input.tokens.length - 1 + baseTokens.length\n );\n uint256 metaLPTokenIndex = input.tokens.length - 1;\n for (uint256 i = 0; i < metaLPTokenIndex; i++) {\n underlyingTokens[i] = input.tokens[i];\n }\n for (uint256 i = metaLPTokenIndex; i < underlyingTokens.length; i++) {\n underlyingTokens[i] = baseTokens[i - metaLPTokenIndex];\n }\n\n IPoolRegistry.PoolData memory poolData = IPoolRegistry.PoolData({\n poolAddress: deployedMetaSwap,\n lpToken: lpToken,\n typeOfAsset: input.typeOfAsset,\n poolName: input.poolName,\n targetAddress: targetSwap,\n tokens: input.tokens,\n underlyingTokens: underlyingTokens,\n basePoolAddress: input.baseSwap,\n metaSwapDepositAddress: deployedMetaSwapDeposit,\n isSaddleApproved: false,\n isRemoved: false,\n isGuarded: false\n });\n\n emit NewSwapPool(msg.sender, deployedMetaSwap, input.tokens);\n emit NewSwapPool(msg.sender, deployedMetaSwapDeposit, underlyingTokens);\n\n poolRegistryCached.addCommunityPool(poolData);\n }\n\n /**\n * @notice Updates cached address of the pool registry **should be onlymanager?\n */\n function updatePoolRegistryCache() external {\n _updatePoolRegistryCache(address(MASTER_REGISTRY));\n }\n\n function _updatePoolRegistryCache(address masterRegistry) internal {\n poolRegistryCached = IPoolRegistry(\n IMasterRegistry(masterRegistry).resolveNameToLatestAddress(\n POOL_REGISTRY_NAME\n )\n );\n }\n\n function setTargetLPToken(address _targetLPToken)\n external\n payable\n onlyManager\n {\n _setTargetLPToken(_targetLPToken);\n }\n\n function _setTargetLPToken(address _targetLPToken) internal {\n require(\n address(_targetLPToken) != address(0),\n \"Target LPToken cannot be 0\"\n );\n targetLPToken = _targetLPToken;\n emit TargetLPTokenUpdated(_targetLPToken);\n }\n\n function setTargetSwap(address _targetSwap) external payable onlyManager {\n _setTargetSwap(_targetSwap);\n }\n\n function _setTargetSwap(address _targetSwap) internal {\n require(address(_targetSwap) != address(0), \"Target Swap cannot be 0\");\n targetSwap = _targetSwap;\n emit TargetSwapUpdated(_targetSwap);\n }\n\n function setTargetMetaSwap(address _targetMetaSwap)\n public\n payable\n onlyManager\n {\n _setTargetMetaSwap(_targetMetaSwap);\n }\n\n function _setTargetMetaSwap(address _targetMetaSwap) internal {\n require(\n address(_targetMetaSwap) != address(0),\n \"Target MetaSwap cannot be 0\"\n );\n targetMetaSwap = _targetMetaSwap;\n emit TargetMetaSwapUpdated(_targetMetaSwap);\n }\n\n function setTargetMetaSwapDeposit(address _targetMetaSwapDeposit)\n external\n payable\n onlyManager\n {\n _setTargetMetaSwapDeposit(_targetMetaSwapDeposit);\n }\n\n function _setTargetMetaSwapDeposit(address _targetMetaSwapDeposit)\n internal\n {\n require(\n address(_targetMetaSwapDeposit) != address(0),\n \"Target MetaSwapDeposit cannot be 0\"\n );\n targetMetaSwapDeposit = _targetMetaSwapDeposit;\n emit TargetMetaSwapDepositUpdated(_targetMetaSwapDeposit);\n }\n}\n" + }, + "contracts/permissionless/PermissionlessMetaSwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"./PermissionlessSwap.sol\";\nimport \"./ShareProtocolFee.sol\";\nimport \"../meta/MetaSwapUtils.sol\";\nimport \"../meta/MetaSwap.sol\";\n\n/**\n * @title MetaSwap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\n *\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract PermissionlessMetaSwap is MetaSwap, ShareProtocolFee {\n using PermissionlessSwapUtils for SwapUtils.Swap;\n\n /**\n * @notice Constructor for the PermissionlessSwap contract.\n * @param _masterRegistry address of the MasterRegistry contract\n */\n constructor(IMasterRegistry _masterRegistry)\n public\n ShareProtocolFee(_masterRegistry)\n {}\n\n /*** ADMIN FUNCTIONS ***/\n\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwap baseSwap\n ) public payable virtual override initializer {\n MetaSwap.initializeMetaSwap(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress,\n baseSwap\n );\n _updateFeeCollectorCache(MASTER_REGISTRY);\n }\n\n /**\n * @notice Withdraw all admin fees to the contract owner and the fee collector\n */\n function withdrawAdminFees()\n external\n payable\n virtual\n override(ShareProtocolFee, Swap)\n {\n require(\n msg.sender == owner() || msg.sender == feeCollector,\n \"Caller is not authorized\"\n );\n PermissionlessSwapUtils.withdrawAdminFees(\n swapStorage,\n owner(),\n feeCollector\n );\n }\n}\n" + }, + "contracts/permissionless/PermissionlessMetaSwapFlashLoan.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"./PermissionlessMetaSwap.sol\";\nimport \"./FlashLoanEnabled.sol\";\nimport \"../interfaces/IFlashLoanReceiver.sol\";\n\n/**\n * @title MetaSwap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\n *\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract PermissionlessMetaSwapFlashLoan is\n PermissionlessMetaSwap,\n FlashLoanEnabled\n{\n /**\n * @notice Constructor for the PermissionlessSwapFlashLoan contract.\n * @param _masterRegistry address of the MasterRegistry contract\n */\n constructor(IMasterRegistry _masterRegistry)\n public\n PermissionlessMetaSwap(_masterRegistry)\n {}\n\n /**\n * @inheritdoc MetaSwap\n * @dev Additionally sets flashloan fees.\n */\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwap baseSwap\n ) public payable virtual override initializer {\n MetaSwap.initializeMetaSwap(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress,\n baseSwap\n );\n // Set flashLoanFeeBPS to 8 and protocolFeeShareBPS to 0\n _setFlashLoanFees(8, 0);\n _updateFeeCollectorCache(MASTER_REGISTRY);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /// @inheritdoc FlashLoanEnabled\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external payable virtual override nonReentrant {\n uint8 tokenIndex = getTokenIndex(address(token));\n uint256 availableLiquidityBefore = token.balanceOf(address(this));\n uint256 protocolBalanceBefore = availableLiquidityBefore.sub(\n swapStorage.balances[tokenIndex]\n );\n require(\n amount > 0 && availableLiquidityBefore >= amount,\n \"invalid amount\"\n );\n\n // Calculate the additional amount of tokens the pool should end up with\n uint256 amountFee = amount.mul(flashLoanFeeBPS).div(10000);\n // Calculate the portion of the fee that will go to the protocol\n uint256 protocolFee = amountFee.mul(protocolFeeShareBPS).div(10000);\n require(amountFee > 0, \"amount is small for a flashLoan\");\n\n // Transfer the requested amount of tokens\n token.safeTransfer(receiver, amount);\n\n // Execute callback function on receiver\n IFlashLoanReceiver(receiver).executeOperation(\n address(this),\n address(token),\n amount,\n amountFee,\n params\n );\n\n uint256 availableLiquidityAfter = token.balanceOf(address(this));\n require(\n availableLiquidityAfter >= availableLiquidityBefore.add(amountFee),\n \"flashLoan fee is not met\"\n );\n\n swapStorage.balances[tokenIndex] = availableLiquidityAfter\n .sub(protocolBalanceBefore)\n .sub(protocolFee);\n emit FlashLoan(receiver, tokenIndex, amount, amountFee, protocolFee);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the flash loan fee parameters. Only owner can call this function.\n * @dev This function should be overridden for permissions.\n * @param newFlashLoanFeeBPS the total fee in bps to be applied on future flash loans\n * @param newProtocolFeeShareBPS the protocol fee in bps to be applied on the total flash loan fee\n */\n function setFlashLoanFees(\n uint256 newFlashLoanFeeBPS,\n uint256 newProtocolFeeShareBPS\n ) external payable virtual onlyOwner {\n _setFlashLoanFees(newFlashLoanFeeBPS, newProtocolFeeShareBPS);\n }\n}\n" + }, + "contracts/permissionless/PermissionlessSwap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"../Swap.sol\";\nimport \"../interfaces/IMasterRegistry.sol\";\nimport \"./PermissionlessSwapUtils.sol\";\nimport \"./ShareProtocolFee.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs. Part of this fee is given to the creator of the pool as an Admin fee,\n * the amount of which is set when the pool is created. Saddle will collect to 50% of these Admin fees.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `PermissionlessSwapUtils` for the sake of reducing\n * contract's deployment size.\n */\ncontract PermissionlessSwap is Swap, ShareProtocolFee {\n using PermissionlessSwapUtils for SwapUtils.Swap;\n\n /**\n * @notice Constructor for the PermissionlessSwap contract.\n * @param _masterRegistry address of the MasterRegistry contract\n */\n constructor(IMasterRegistry _masterRegistry)\n public\n ShareProtocolFee(_masterRegistry)\n {}\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates cached address of the fee collector\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual override initializer {\n Swap.initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n _updateFeeCollectorCache(MASTER_REGISTRY);\n }\n\n /**\n * @notice Withdraw all admin fees to the contract owner and the fee collector.\n */\n function withdrawAdminFees()\n external\n payable\n virtual\n override(Swap, ShareProtocolFee)\n {\n require(\n msg.sender == owner() || msg.sender == feeCollector,\n \"Caller is not authorized\"\n );\n PermissionlessSwapUtils.withdrawAdminFees(\n swapStorage,\n owner(),\n feeCollector\n );\n }\n}\n" + }, + "contracts/permissionless/PermissionlessSwapFlashLoan.sol": { + "content": "// SPDX-License-Identifier: MIT WITH AGPL-3.0-only\n\npragma solidity 0.6.12;\n\nimport \"./PermissionlessSwap.sol\";\nimport \"./FlashLoanEnabled.sol\";\nimport \"../interfaces/IFlashLoanReceiver.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract PermissionlessSwapFlashLoan is PermissionlessSwap, FlashLoanEnabled {\n /**\n * @notice Constructor for the PermissionlessSwapFlashLoan contract.\n * @param _masterRegistry address of the MasterRegistry contract\n */\n constructor(IMasterRegistry _masterRegistry)\n public\n PermissionlessSwap(_masterRegistry)\n {}\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual override initializer {\n Swap.initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n // Set flashLoanFeeBPS to 8 and protocolFeeShareBPS to 0\n _setFlashLoanFees(8, 0);\n _updateFeeCollectorCache(MASTER_REGISTRY);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /// @inheritdoc FlashLoanEnabled\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external payable override nonReentrant {\n uint8 tokenIndex = getTokenIndex(address(token));\n uint256 availableLiquidityBefore = token.balanceOf(address(this));\n uint256 protocolBalanceBefore = availableLiquidityBefore.sub(\n swapStorage.balances[tokenIndex]\n );\n require(\n amount > 0 && availableLiquidityBefore >= amount,\n \"invalid amount\"\n );\n\n // Calculate the additional amount of tokens the pool should end up with\n uint256 amountFee = amount.mul(flashLoanFeeBPS).div(10000);\n // Calculate the portion of the fee that will go to the protocol\n uint256 protocolFee = amountFee.mul(protocolFeeShareBPS).div(10000);\n require(amountFee > 0, \"amount is small for a flashLoan\");\n\n // Transfer the requested amount of tokens\n token.safeTransfer(receiver, amount);\n\n // Execute callback function on receiver\n IFlashLoanReceiver(receiver).executeOperation(\n address(this),\n address(token),\n amount,\n amountFee,\n params\n );\n\n uint256 availableLiquidityAfter = token.balanceOf(address(this));\n require(\n availableLiquidityAfter >= availableLiquidityBefore.add(amountFee),\n \"flashLoan fee is not met\"\n );\n\n swapStorage.balances[tokenIndex] = availableLiquidityAfter\n .sub(protocolBalanceBefore)\n .sub(protocolFee);\n emit FlashLoan(receiver, tokenIndex, amount, amountFee, protocolFee);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the flash loan fee parameters. Only owner can call this function.\n * @dev This function should be overridden for permissions.\n * @param newFlashLoanFeeBPS the total fee in bps to be applied on future flash loans\n * @param newProtocolFeeShareBPS the protocol fee in bps to be applied on the total flash loan fee\n */\n function setFlashLoanFees(\n uint256 newFlashLoanFeeBPS,\n uint256 newProtocolFeeShareBPS\n ) external payable virtual onlyOwner {\n _setFlashLoanFees(newFlashLoanFeeBPS, newProtocolFeeShareBPS);\n }\n}\n" + }, + "contracts/permissionless/PermissionlessSwapUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"../SwapUtils.sol\";\n\n/**\n * @title PermissionlessSwapUtils library\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary PermissionlessSwapUtils {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n /**\n * @notice Withdraw all admin fees to two addresses evenly\n * @param self Swap struct to withdraw fees from\n * @param creator Address to send hald of the fees to. For the creator of the community pool.\n * @param protocol Address to send the half of the fees to. For the protocol fee collection.\n */\n function withdrawAdminFees(\n SwapUtils.Swap storage self,\n address creator,\n address protocol\n ) internal {\n IERC20[] memory pooledTokens = self.pooledTokens;\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n IERC20 token = pooledTokens[i];\n uint256 balance = token.balanceOf(address(this)).sub(\n self.balances[i]\n ) / 2;\n if (balance != 0) {\n token.safeTransfer(creator, balance);\n token.safeTransfer(protocol, balance);\n }\n }\n }\n}\n" + }, + "contracts/permissionless/ShareProtocolFee.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\nimport \"../interfaces/IMasterRegistry.sol\";\n\nabstract contract ShareProtocolFee {\n IMasterRegistry public immutable MASTER_REGISTRY;\n bytes32 public constant FEE_COLLECTOR_NAME =\n 0x466565436f6c6c6563746f720000000000000000000000000000000000000000;\n address public feeCollector;\n\n constructor(IMasterRegistry _masterRegistry) public {\n MASTER_REGISTRY = _masterRegistry;\n _updateFeeCollectorCache(_masterRegistry);\n }\n\n /**\n * @notice Updates cached address of the fee collector\n */\n function updateFeeCollectorCache() public payable virtual {\n _updateFeeCollectorCache(MASTER_REGISTRY);\n }\n\n function _updateFeeCollectorCache(IMasterRegistry masterRegistry)\n internal\n virtual\n {\n address _feeCollector = masterRegistry.resolveNameToLatestAddress(\n FEE_COLLECTOR_NAME\n );\n require(_feeCollector != address(0), \"Fee collector cannot be empty\");\n feeCollector = _feeCollector;\n }\n\n /**\n * @notice Withdraws admin fees to appropriate addresses\n */\n function withdrawAdminFees() external payable virtual;\n}\n" + }, + "contracts/registries/MasterRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"../helper/BaseBoringBatchable.sol\";\nimport \"../interfaces/IMasterRegistry.sol\";\n\n/**\n * @title MasterRegistry\n * @notice This contract holds list of other registries or contracts and its historical versions.\n */\ncontract MasterRegistry is AccessControl, IMasterRegistry, BaseBoringBatchable {\n /// @notice Role responsible for adding registries.\n bytes32 public constant SADDLE_MANAGER_ROLE =\n keccak256(\"SADDLE_MANAGER_ROLE\");\n\n mapping(bytes32 => address[]) private registryMap;\n mapping(address => ReverseRegistryData) private reverseRegistry;\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param name address of the added pool\n * @param registryAddress address of the registry\n * @param version version of the registry\n */\n event AddRegistry(\n bytes32 indexed name,\n address registryAddress,\n uint256 version\n );\n\n constructor(address admin) public {\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\n }\n\n /// @inheritdoc IMasterRegistry\n function addRegistry(bytes32 registryName, address registryAddress)\n external\n payable\n override\n {\n require(\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\n \"MR: msg.sender is not allowed\"\n );\n require(registryName != 0, \"MR: name cannot be empty\");\n require(registryAddress != address(0), \"MR: address cannot be empty\");\n\n address[] storage registry = registryMap[registryName];\n uint256 version = registry.length;\n registry.push(registryAddress);\n require(\n reverseRegistry[registryAddress].name == 0,\n \"MR: duplicate registry address\"\n );\n reverseRegistry[registryAddress] = ReverseRegistryData(\n registryName,\n version\n );\n\n emit AddRegistry(registryName, registryAddress, version);\n }\n\n /// @inheritdoc IMasterRegistry\n function resolveNameToLatestAddress(bytes32 name)\n external\n view\n override\n returns (address)\n {\n address[] storage registry = registryMap[name];\n uint256 length = registry.length;\n require(length > 0, \"MR: no match found for name\");\n return registry[length - 1];\n }\n\n /// @inheritdoc IMasterRegistry\n function resolveNameAndVersionToAddress(bytes32 name, uint256 version)\n external\n view\n override\n returns (address)\n {\n address[] storage registry = registryMap[name];\n require(\n version < registry.length,\n \"MR: no match found for name and version\"\n );\n return registry[version];\n }\n\n /// @inheritdoc IMasterRegistry\n function resolveNameToAllAddresses(bytes32 name)\n external\n view\n override\n returns (address[] memory)\n {\n address[] storage registry = registryMap[name];\n require(registry.length > 0, \"MR: no match found for name\");\n return registry;\n }\n\n /// @inheritdoc IMasterRegistry\n function resolveAddressToRegistryData(address registryAddress)\n external\n view\n override\n returns (\n bytes32 name,\n uint256 version,\n bool isLatest\n )\n {\n ReverseRegistryData memory data = reverseRegistry[registryAddress];\n require(data.name != 0, \"MR: no match found for address\");\n name = data.name;\n version = data.version;\n uint256 length = registryMap[name].length;\n require(length > 0, \"MR: no version found for address\");\n isLatest = version == length - 1;\n }\n}\n" + }, + "contracts/registries/PoolRegistry.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"../helper/BaseBoringBatchable.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"../interfaces/ISwapGuarded.sol\";\nimport \"../interfaces/IMetaSwap.sol\";\nimport \"../interfaces/IPoolRegistry.sol\";\nimport \"../meta/MetaSwapDeposit.sol\";\n\n/**\n * @title PoolRegistry\n * @notice This contract holds list of pools deployed.\n */\ncontract PoolRegistry is\n AccessControl,\n ReentrancyGuard,\n BaseBoringBatchable,\n IPoolRegistry\n{\n using SafeMath for uint256;\n\n /// @notice Role responsible for managing pools.\n bytes32 public constant SADDLE_MANAGER_ROLE =\n keccak256(\"SADDLE_MANAGER_ROLE\");\n /// @notice Role responsible for managing community pools\n bytes32 public constant COMMUNITY_MANAGER_ROLE =\n keccak256(\"COMMUNITY_MANAGER_ROLE\");\n /// @notice Role that represents approved owners of pools.\n /// owner of each pool must have this role if the pool is to be approved.\n bytes32 public constant SADDLE_APPROVED_POOL_OWNER_ROLE =\n keccak256(\"SADDLE_APPROVED_POOL_OWNER_ROLE\");\n\n /// @inheritdoc IPoolRegistry\n mapping(address => uint256) public override poolsIndexOfPlusOne;\n /// @inheritdoc IPoolRegistry\n mapping(bytes32 => uint256) public override poolsIndexOfNamePlusOne;\n\n PoolData[] private pools;\n mapping(uint256 => address[]) private eligiblePairsMap;\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param poolAddress address of the added pool\n * @param index index of the added pool in the pools list\n * @param poolData added pool data\n */\n event AddPool(\n address indexed poolAddress,\n uint256 index,\n PoolData poolData\n );\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param poolAddress address of the added pool\n * @param index index of the added pool in the pools list\n * @param poolData added pool data\n */\n event AddCommunityPool(\n address indexed poolAddress,\n uint256 index,\n PoolData poolData\n );\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param poolAddress address of the updated pool\n * @param index index of the updated pool in the pools list\n * @param poolData updated pool data\n */\n event UpdatePool(\n address indexed poolAddress,\n uint256 index,\n PoolData poolData\n );\n\n /**\n * @notice Add a new registry entry to the master list.\n * @param poolAddress address of the removed pool\n * @param index index of the removed pool in the pools list\n */\n event RemovePool(address indexed poolAddress, uint256 index);\n\n /**\n * @notice Deploy this contract and set appropriate roles\n * @param admin address who should have the DEFAULT_ADMIN_ROLE\n * @dev caller of this function will be set as the owner on deployment\n */\n constructor(address admin, address poolOwner) public payable {\n require(admin != address(0), \"admin == 0\");\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\n _setupRole(SADDLE_MANAGER_ROLE, msg.sender);\n _setupRole(SADDLE_APPROVED_POOL_OWNER_ROLE, poolOwner);\n }\n\n /// @inheritdoc IPoolRegistry\n function addCommunityPool(PoolData memory data) external payable override {\n require(\n hasRole(COMMUNITY_MANAGER_ROLE, msg.sender),\n \"PR: Only managers can add pools\"\n );\n\n // Check token addresses\n for (uint8 i = 0; i < data.tokens.length; i++) {\n for (uint8 j = 0; j < i; j++) {\n eligiblePairsMap[\n uint160(address(data.tokens[i])) ^\n uint160(address(data.tokens[j]))\n ].push(data.poolAddress);\n }\n }\n\n // Check meta swap deposit address\n if (data.metaSwapDepositAddress != address(0)) {\n for (uint8 i = 0; i < data.underlyingTokens.length; i++) {\n // add combinations of tokens to eligible pairs map\n // i reprents the indexes of the underlying tokens of metaLPToken.\n // j represents the indexes of MetaSwap level tokens that are not metaLPToken.\n // Example: tokens = [sUSD, baseLPToken]\n // underlyingTokens = [sUSD, DAI, USDC, USDT]\n // i represents index of [DAI, USDC, USDT] in underlyingTokens\n // j represents index of [sUSD] in underlyingTokens\n if (i > data.tokens.length.sub(2))\n for (uint256 j = 0; j < data.tokens.length - 1; j++) {\n eligiblePairsMap[\n uint160(address(data.underlyingTokens[i])) ^\n uint160(address(data.underlyingTokens[j]))\n ].push(data.metaSwapDepositAddress);\n }\n }\n }\n\n pools.push(data);\n poolsIndexOfPlusOne[data.poolAddress] = pools.length;\n poolsIndexOfNamePlusOne[data.poolName] = pools.length;\n\n emit AddCommunityPool(data.poolAddress, pools.length - 1, data);\n }\n\n /// @inheritdoc IPoolRegistry\n function addPool(PoolInputData memory inputData)\n external\n payable\n override\n nonReentrant\n {\n require(\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\n \"PR: Only managers can add pools\"\n );\n require(inputData.poolAddress != address(0), \"PR: poolAddress is 0\");\n require(\n poolsIndexOfPlusOne[inputData.poolAddress] == 0,\n \"PR: Pool is already added\"\n );\n\n IERC20[] memory tokens = new IERC20[](8);\n IERC20[] memory underlyingTokens = new IERC20[](8);\n\n PoolData memory data = PoolData(\n inputData.poolAddress,\n address(0),\n inputData.typeOfAsset,\n inputData.poolName,\n inputData.targetAddress,\n tokens,\n underlyingTokens,\n address(0),\n inputData.metaSwapDepositAddress,\n inputData.isSaddleApproved,\n inputData.isRemoved,\n inputData.isGuarded\n );\n\n // Get lp token address\n data.lpToken = inputData.isGuarded\n ? _getSwapStorageGuarded(inputData.poolAddress).lpToken\n : _getSwapStorage(inputData.poolAddress).lpToken;\n\n // Check token addresses\n for (uint8 i = 0; i < 8; i++) {\n try ISwap(inputData.poolAddress).getToken(i) returns (\n IERC20 token\n ) {\n require(address(token) != address(0), \"PR: token is 0\");\n tokens[i] = token;\n // add combinations of tokens to eligible pairs map\n for (uint8 j = 0; j < i; j++) {\n eligiblePairsMap[\n uint160(address(tokens[i])) ^\n uint160(address(tokens[j]))\n ].push(inputData.poolAddress);\n }\n } catch {\n assembly {\n mstore(tokens, sub(mload(tokens), sub(8, i)))\n }\n break;\n }\n }\n\n // Check meta swap deposit address\n if (inputData.metaSwapDepositAddress != address(0)) {\n // Get base pool address\n data.basePoolAddress = address(\n MetaSwapDeposit(inputData.metaSwapDepositAddress).baseSwap()\n );\n require(\n poolsIndexOfPlusOne[data.basePoolAddress] > 0,\n \"PR: base pool not found\"\n );\n\n // Get underlying tokens\n for (uint8 i = 0; i < 8; i++) {\n try\n MetaSwapDeposit(inputData.metaSwapDepositAddress).getToken(\n i\n )\n returns (IERC20 token) {\n require(address(token) != address(0), \"PR: token is 0\");\n underlyingTokens[i] = token;\n // add combinations of tokens to eligible pairs map\n // i reprents the indexes of the underlying tokens of metaLPToken.\n // j represents the indexes of MetaSwap level tokens that are not metaLPToken.\n // Example: tokens = [sUSD, baseLPToken]\n // underlyingTokens = [sUSD, DAI, USDC, USDT]\n // i represents index of [DAI, USDC, USDT] in underlyingTokens\n // j represents index of [sUSD] in underlyingTokens\n if (i > tokens.length.sub(2))\n for (uint256 j = 0; j < tokens.length - 1; j++) {\n eligiblePairsMap[\n uint160(address(underlyingTokens[i])) ^\n uint160(address(underlyingTokens[j]))\n ].push(inputData.metaSwapDepositAddress);\n }\n } catch {\n assembly {\n mstore(\n underlyingTokens,\n sub(mload(underlyingTokens), sub(8, i))\n )\n }\n break;\n }\n }\n require(\n address(\n MetaSwapDeposit(inputData.metaSwapDepositAddress).metaSwap()\n ) == inputData.poolAddress,\n \"PR: metaSwap address mismatch\"\n );\n } else {\n assembly {\n mstore(underlyingTokens, sub(mload(underlyingTokens), 8))\n }\n }\n\n pools.push(data);\n poolsIndexOfPlusOne[data.poolAddress] = pools.length;\n poolsIndexOfNamePlusOne[data.poolName] = pools.length;\n\n emit AddPool(inputData.poolAddress, pools.length - 1, data);\n }\n\n /// @inheritdoc IPoolRegistry\n function approvePool(address poolAddress)\n external\n payable\n override\n managerOnly\n {\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];\n require(poolIndex > 0, \"PR: Pool not found\");\n\n PoolData storage poolData = pools[poolIndex];\n\n require(\n poolData.poolAddress == poolAddress,\n \"PR: poolAddress mismatch\"\n );\n\n // Effect\n poolData.isSaddleApproved = true;\n\n // Interaction\n require(\n hasRole(\n SADDLE_APPROVED_POOL_OWNER_ROLE,\n ISwap(poolAddress).owner()\n ),\n \"Pool is not owned by saddle\"\n );\n\n emit UpdatePool(poolAddress, poolIndex, poolData);\n }\n\n /// @inheritdoc IPoolRegistry\n function updatePool(PoolData memory poolData)\n external\n payable\n override\n managerOnly\n {\n uint256 poolIndex = poolsIndexOfPlusOne[poolData.poolAddress];\n require(poolIndex > 0, \"PR: Pool not found\");\n poolIndex -= 1;\n\n pools[poolIndex] = poolData;\n\n emit UpdatePool(poolData.poolAddress, poolIndex, poolData);\n }\n\n /// @inheritdoc IPoolRegistry\n function removePool(address poolAddress)\n external\n payable\n override\n managerOnly\n {\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress];\n require(poolIndex > 0, \"PR: Pool not found\");\n poolIndex -= 1;\n\n pools[poolIndex].isRemoved = true;\n\n emit RemovePool(poolAddress, poolIndex);\n }\n\n /// @inheritdoc IPoolRegistry\n function getPoolDataAtIndex(uint256 index)\n external\n view\n override\n returns (PoolData memory)\n {\n require(index < pools.length, \"PR: Index out of bounds\");\n return pools[index];\n }\n\n /// @inheritdoc IPoolRegistry\n function getPoolData(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (PoolData memory)\n {\n return pools[poolsIndexOfPlusOne[poolAddress] - 1];\n }\n\n /// @inheritdoc IPoolRegistry\n function getPoolDataByName(bytes32 poolName)\n external\n view\n override\n returns (PoolData memory)\n {\n uint256 index = poolsIndexOfNamePlusOne[poolName];\n require(index > 0, \"PR: Pool not found\");\n return pools[index - 1];\n }\n\n modifier hasMatchingPool(address poolAddress) {\n require(\n poolsIndexOfPlusOne[poolAddress] > 0,\n \"PR: No matching pool found\"\n );\n _;\n }\n\n modifier managerOnly() {\n require(\n hasRole(SADDLE_MANAGER_ROLE, msg.sender),\n \"PR: Caller is not saddle manager\"\n );\n _;\n }\n\n /// @inheritdoc IPoolRegistry\n function getVirtualPrice(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (uint256)\n {\n return ISwap(poolAddress).getVirtualPrice();\n }\n\n /// @inheritdoc IPoolRegistry\n function getA(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (uint256)\n {\n return ISwap(poolAddress).getA();\n }\n\n /// @inheritdoc IPoolRegistry\n function getPaused(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (bool)\n {\n return ISwap(poolAddress).paused();\n }\n\n /// @inheritdoc IPoolRegistry\n function getSwapStorage(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (SwapStorageData memory swapStorageData)\n {\n swapStorageData = pools[poolsIndexOfPlusOne[poolAddress] - 1].isGuarded\n ? _getSwapStorageGuarded(poolAddress)\n : _getSwapStorage(poolAddress);\n }\n\n function _getSwapStorage(address poolAddress)\n internal\n view\n returns (SwapStorageData memory swapStorageData)\n {\n (\n swapStorageData.initialA,\n swapStorageData.futureA,\n swapStorageData.initialATime,\n swapStorageData.futureATime,\n swapStorageData.swapFee,\n swapStorageData.adminFee,\n swapStorageData.lpToken\n ) = ISwap(poolAddress).swapStorage();\n }\n\n function _getSwapStorageGuarded(address poolAddress)\n internal\n view\n returns (SwapStorageData memory swapStorageData)\n {\n (\n swapStorageData.initialA,\n swapStorageData.futureA,\n swapStorageData.initialATime,\n swapStorageData.futureATime,\n swapStorageData.swapFee,\n swapStorageData.adminFee,\n ,\n swapStorageData.lpToken\n ) = ISwapGuarded(poolAddress).swapStorage();\n }\n\n /// @inheritdoc IPoolRegistry\n function getTokens(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (IERC20[] memory tokens)\n {\n return pools[poolsIndexOfPlusOne[poolAddress] - 1].tokens;\n }\n\n /// @inheritdoc IPoolRegistry\n function getUnderlyingTokens(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (IERC20[] memory underlyingTokens)\n {\n return pools[poolsIndexOfPlusOne[poolAddress] - 1].underlyingTokens;\n }\n\n /// @inheritdoc IPoolRegistry\n function getPoolsLength() external view override returns (uint256) {\n return pools.length;\n }\n\n /// @inheritdoc IPoolRegistry\n function getEligiblePools(address from, address to)\n external\n view\n override\n returns (address[] memory eligiblePools)\n {\n require(\n from != address(0) && from != to,\n \"PR: from and to cannot be the zero address\"\n );\n return eligiblePairsMap[uint160(from) ^ uint160(to)];\n }\n\n /// @inheritdoc IPoolRegistry\n function getTokenBalances(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (uint256[] memory balances)\n {\n return _getTokenBalances(poolAddress);\n }\n\n function _getTokenBalances(address poolAddress)\n internal\n view\n returns (uint256[] memory balances)\n {\n uint256 tokensLength = pools[poolsIndexOfPlusOne[poolAddress] - 1]\n .tokens\n .length;\n balances = new uint256[](tokensLength);\n for (uint8 i = 0; i < tokensLength; i++) {\n balances[i] = ISwap(poolAddress).getTokenBalance(i);\n }\n }\n\n /// @inheritdoc IPoolRegistry\n function getUnderlyingTokenBalances(address poolAddress)\n external\n view\n override\n hasMatchingPool(poolAddress)\n returns (uint256[] memory balances)\n {\n uint256 poolIndex = poolsIndexOfPlusOne[poolAddress] - 1;\n address basePoolAddress = pools[poolIndex].basePoolAddress;\n uint256[] memory basePoolBalances = _getTokenBalances(basePoolAddress);\n uint256 underlyingTokensLength = pools[poolIndex]\n .underlyingTokens\n .length;\n uint256 metaLPTokenIndex = underlyingTokensLength -\n basePoolBalances.length;\n uint256 baseLPTokenBalance = ISwap(poolAddress).getTokenBalance(\n uint8(metaLPTokenIndex)\n );\n uint256 baseLPTokenTotalSupply = LPToken(\n pools[poolsIndexOfPlusOne[basePoolAddress] - 1].lpToken\n ).totalSupply();\n\n balances = new uint256[](underlyingTokensLength);\n for (uint8 i = 0; i < metaLPTokenIndex; i++) {\n balances[i] = ISwap(poolAddress).getTokenBalance(i);\n }\n for (uint256 i = metaLPTokenIndex; i < underlyingTokensLength; i++) {\n balances[i] = basePoolBalances[i - metaLPTokenIndex]\n .mul(baseLPTokenBalance)\n .div(baseLPTokenTotalSupply);\n }\n }\n}\n" + }, + "contracts/StakeableTokenWrapper.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// Generalized and adapted from https://github.com/k06a/Unipool 🙇\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\n\n/**\n * @title StakeableTokenWrapper\n * @notice A wrapper for an ERC-20 that can be staked and withdrawn.\n * @dev In this contract, staked tokens don't do anything- instead other\n * contracts can inherit from this one to add functionality.\n */\ncontract StakeableTokenWrapper {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n\n uint256 public totalSupply;\n IERC20 public stakedToken;\n mapping(address => uint256) private _balances;\n\n event Staked(address indexed user, uint256 amount);\n event Withdrawn(address indexed user, uint256 amount);\n\n /**\n * @notice Creates a new StakeableTokenWrapper with given `_stakedToken` address\n * @param _stakedToken address of a token that will be used to stake\n */\n constructor(IERC20 _stakedToken) public {\n stakedToken = _stakedToken;\n }\n\n /**\n * @notice Read how much `account` has staked in this contract\n * @param account address of an account\n * @return amount of total staked ERC20(this.stakedToken) by `account`\n */\n function balanceOf(address account) external view returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @notice Stakes given `amount` in this contract\n * @param amount amount of ERC20(this.stakedToken) to stake\n */\n function stake(uint256 amount) external {\n require(amount != 0, \"amount == 0\");\n totalSupply = totalSupply.add(amount);\n _balances[msg.sender] = _balances[msg.sender].add(amount);\n stakedToken.safeTransferFrom(msg.sender, address(this), amount);\n emit Staked(msg.sender, amount);\n }\n\n /**\n * @notice Withdraws given `amount` from this contract\n * @param amount amount of ERC20(this.stakedToken) to withdraw\n */\n function withdraw(uint256 amount) external {\n totalSupply = totalSupply.sub(amount);\n _balances[msg.sender] = _balances[msg.sender].sub(amount);\n stakedToken.safeTransfer(msg.sender, amount);\n emit Withdrawn(msg.sender, amount);\n }\n}\n" + }, + "contracts/Swap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\nimport \"./OwnerPausableUpgradeable.sol\";\nimport \"./SwapUtils.sol\";\nimport \"./AmplificationUtils.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract Swap is OwnerPausableUpgradeable, ReentrancyGuardUpgradeable {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using SwapUtils for SwapUtils.Swap;\n using AmplificationUtils for SwapUtils.Swap;\n\n // Struct storing data responsible for automatic market maker functionalities. In order to\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtils.sol\n SwapUtils.Swap public swapStorage;\n\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\n // getTokenIndex function also relies on this mapping to retrieve token index.\n mapping(address => uint8) private tokenIndexes;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual initializer {\n __OwnerPausable_init();\n __ReentrancyGuard_init();\n // Check _pooledTokens and precisions parameter\n require(_pooledTokens.length > 1, \"_pooledTokens.length <= 1\");\n require(_pooledTokens.length <= 32, \"_pooledTokens.length > 32\");\n require(\n _pooledTokens.length == decimals.length,\n \"_pooledTokens decimals mismatch\"\n );\n\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\n\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\n if (i > 0) {\n // Check if index is already used. Check if 0th element is a duplicate.\n require(\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\n _pooledTokens[0] != _pooledTokens[i],\n \"Duplicate tokens\"\n );\n }\n require(\n address(_pooledTokens[i]) != address(0),\n \"The 0 address isn't an ERC-20\"\n );\n require(\n decimals[i] <= SwapUtils.POOL_PRECISION_DECIMALS,\n \"Token decimals exceeds max\"\n );\n precisionMultipliers[i] =\n 10 **\n uint256(SwapUtils.POOL_PRECISION_DECIMALS).sub(\n uint256(decimals[i])\n );\n tokenIndexes[address(_pooledTokens[i])] = i;\n }\n\n // Check _a, _fee, _adminFee, _withdrawFee parameters\n require(_a < AmplificationUtils.MAX_A, \"_a exceeds maximum\");\n require(_fee < SwapUtils.MAX_SWAP_FEE, \"_fee exceeds maximum\");\n require(\n _adminFee < SwapUtils.MAX_ADMIN_FEE,\n \"_adminFee exceeds maximum\"\n );\n\n // Clone and initialize a LPToken contract\n LPToken lpToken = LPToken(Clones.clone(lpTokenTargetAddress));\n require(\n lpToken.initialize(lpTokenName, lpTokenSymbol),\n \"could not init lpToken clone\"\n );\n\n // Initialize swapStorage struct\n swapStorage.lpToken = lpToken;\n swapStorage.pooledTokens = _pooledTokens;\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\n swapStorage.balances = new uint256[](_pooledTokens.length);\n swapStorage.initialA = _a.mul(AmplificationUtils.A_PRECISION);\n swapStorage.futureA = _a.mul(AmplificationUtils.A_PRECISION);\n // swapStorage.initialATime = 0;\n // swapStorage.futureATime = 0;\n swapStorage.swapFee = _fee;\n swapStorage.adminFee = _adminFee;\n }\n\n /*** MODIFIERS ***/\n\n /**\n * @notice Modifier to check deadline against current timestamp\n * @param deadline latest timestamp to accept this transaction\n */\n modifier deadlineCheck(uint256 deadline) {\n require(block.timestamp <= deadline, \"Deadline not met\");\n _;\n }\n\n /*** VIEW FUNCTIONS ***/\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @return A parameter\n */\n function getA() external view virtual returns (uint256) {\n return swapStorage.getA();\n }\n\n /**\n * @notice Return A in its raw precision form\n * @dev See the StableSwap paper for details\n * @return A parameter in its raw precision form\n */\n function getAPrecise() external view virtual returns (uint256) {\n return swapStorage.getAPrecise();\n }\n\n /**\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) public view virtual returns (IERC20) {\n require(index < swapStorage.pooledTokens.length, \"Out of range\");\n return swapStorage.pooledTokens[index];\n }\n\n /**\n * @notice Return the index of the given token address. Reverts if no matching\n * token is found.\n * @param tokenAddress address of the token\n * @return the index of the given token address\n */\n function getTokenIndex(address tokenAddress)\n public\n view\n virtual\n returns (uint8)\n {\n uint8 index = tokenIndexes[tokenAddress];\n require(\n address(getToken(index)) == tokenAddress,\n \"Token does not exist\"\n );\n return index;\n }\n\n /**\n * @notice Return current balance of the pooled token at given index\n * @param index the index of the token\n * @return current balance of the pooled token at given index with token's native precision\n */\n function getTokenBalance(uint8 index)\n external\n view\n virtual\n returns (uint256)\n {\n require(index < swapStorage.pooledTokens.length, \"Index out of range\");\n return swapStorage.balances[index];\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice() external view virtual returns (uint256) {\n return swapStorage.getVirtualPrice();\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual returns (uint256) {\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.calculateTokenAmount(amounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n virtual\n returns (uint256[] memory)\n {\n return swapStorage.calculateRemoveLiquidity(amount);\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view virtual returns (uint256 availableTokenAmount) {\n return swapStorage.calculateWithdrawOneToken(tokenAmount, tokenIndex);\n }\n\n /**\n * @notice This function reads the accumulated amount of admin fees of the token with given index\n * @param index Index of the pooled token\n * @return admin's token balance in the token's precision\n */\n function getAdminBalance(uint256 index)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.getAdminBalance(index);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.addLiquidity(amounts, minToMint);\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n deadlineCheck(deadline)\n returns (uint256[] memory)\n {\n return swapStorage.removeLiquidity(amount, minAmounts);\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n swapStorage.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Withdraw all admin fees to the contract owner\n */\n function withdrawAdminFees() external payable virtual onlyOwner {\n swapStorage.withdrawAdminFees(owner());\n }\n\n /**\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(uint256 newAdminFee) external payable onlyOwner {\n swapStorage.setAdminFee(newAdminFee);\n }\n\n /**\n * @notice Update the swap fee to be applied on swaps\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(uint256 newSwapFee) external payable onlyOwner {\n swapStorage.setSwapFee(newSwapFee);\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param futureA the new A to ramp towards\n * @param futureTime timestamp when the new A should be reached\n */\n function rampA(uint256 futureA, uint256 futureTime)\n external\n payable\n onlyOwner\n {\n swapStorage.rampA(futureA, futureTime);\n }\n\n /**\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\n */\n function stopRampA() external payable onlyOwner {\n swapStorage.stopRampA();\n }\n}\n" + }, + "contracts/SwapDeployer.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"./interfaces/ISwap.sol\";\nimport \"./interfaces/IMetaSwap.sol\";\n\ncontract SwapDeployer is Ownable {\n event NewSwapPool(\n address indexed deployer,\n address swapAddress,\n IERC20[] pooledTokens\n );\n event NewClone(address indexed target, address cloneAddress);\n\n constructor() public Ownable() {}\n\n function clone(address target) external returns (address) {\n address newClone = _clone(target);\n emit NewClone(target, newClone);\n\n return newClone;\n }\n\n function _clone(address target) internal returns (address) {\n return Clones.clone(target);\n }\n\n function deploy(\n address swapAddress,\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) external returns (address) {\n address swapClone = _clone(swapAddress);\n ISwap(swapClone).initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n Ownable(swapClone).transferOwnership(owner());\n emit NewSwapPool(msg.sender, swapClone, _pooledTokens);\n return swapClone;\n }\n\n function deployMetaSwap(\n address metaSwapAddress,\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwap baseSwap\n ) external returns (address) {\n address metaSwapClone = _clone(metaSwapAddress);\n IMetaSwap(metaSwapClone).initializeMetaSwap(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress,\n baseSwap\n );\n Ownable(metaSwapClone).transferOwnership(owner());\n emit NewSwapPool(msg.sender, metaSwapClone, _pooledTokens);\n return metaSwapClone;\n }\n}\n" + }, + "contracts/SwapDeployerV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"./interfaces/ISwapV1.sol\";\n\ncontract SwapDeployerV1 is Ownable {\n event NewSwapPool(\n address indexed deployer,\n address swapAddress,\n IERC20[] pooledTokens\n );\n\n constructor() public Ownable() {}\n\n function deploy(\n address swapAddress,\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n uint256 _withdrawFee,\n address lpTokenTargetAddress\n ) external returns (address) {\n address swapClone = Clones.clone(swapAddress);\n ISwapV1(swapClone).initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n _withdrawFee,\n lpTokenTargetAddress\n );\n Ownable(swapClone).transferOwnership(owner());\n emit NewSwapPool(msg.sender, swapClone, _pooledTokens);\n return swapClone;\n }\n}\n" + }, + "contracts/SwapFlashLoan.sol": { + "content": "// SPDX-License-Identifier: MIT WITH AGPL-3.0-only\n\npragma solidity 0.6.12;\n\nimport \"./Swap.sol\";\nimport \"./interfaces/IFlashLoanReceiver.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract SwapFlashLoan is Swap {\n // Total fee that is charged on all flashloans in BPS. Borrowers must repay the amount plus the flash loan fee.\n // This fee is split between the protocol and the pool.\n uint256 public flashLoanFeeBPS;\n // Share of the flash loan fee that goes to the protocol in BPS. A portion of each flash loan fee is allocated\n // to the protocol rather than the pool.\n uint256 public protocolFeeShareBPS;\n // Max BPS for limiting flash loan fee settings.\n uint256 public constant MAX_BPS = 10000;\n\n /*** EVENTS ***/\n event FlashLoan(\n address indexed receiver,\n uint8 tokenIndex,\n uint256 amount,\n uint256 amountFee,\n uint256 protocolFee\n );\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual override initializer {\n Swap.initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n flashLoanFeeBPS = 8; // 8 bps\n protocolFeeShareBPS = 0; // 0 bps\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Borrow the specified token from this pool for this transaction only. This function will call\n * `IFlashLoanReceiver(receiver).executeOperation` and the `receiver` must return the full amount of the token\n * and the associated fee by the end of the callback transaction. If the conditions are not met, this call\n * is reverted.\n * @param receiver the address of the receiver of the token. This address must implement the IFlashLoanReceiver\n * interface and the callback function `executeOperation`.\n * @param token the protocol fee in bps to be applied on the total flash loan fee\n * @param amount the total amount to borrow in this transaction\n * @param params optional data to pass along to the callback function\n */\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external payable nonReentrant {\n uint8 tokenIndex = getTokenIndex(address(token));\n uint256 availableLiquidityBefore = token.balanceOf(address(this));\n uint256 protocolBalanceBefore = availableLiquidityBefore.sub(\n swapStorage.balances[tokenIndex]\n );\n require(\n amount > 0 && availableLiquidityBefore >= amount,\n \"invalid amount\"\n );\n\n // Calculate the additional amount of tokens the pool should end up with\n uint256 amountFee = amount.mul(flashLoanFeeBPS).div(10000);\n // Calculate the portion of the fee that will go to the protocol\n uint256 protocolFee = amountFee.mul(protocolFeeShareBPS).div(10000);\n require(amountFee > 0, \"amount is small for a flashLoan\");\n\n // Transfer the requested amount of tokens\n token.safeTransfer(receiver, amount);\n\n // Execute callback function on receiver\n IFlashLoanReceiver(receiver).executeOperation(\n address(this),\n address(token),\n amount,\n amountFee,\n params\n );\n\n uint256 availableLiquidityAfter = token.balanceOf(address(this));\n require(\n availableLiquidityAfter >= availableLiquidityBefore.add(amountFee),\n \"flashLoan fee is not met\"\n );\n\n swapStorage.balances[tokenIndex] = availableLiquidityAfter\n .sub(protocolBalanceBefore)\n .sub(protocolFee);\n emit FlashLoan(receiver, tokenIndex, amount, amountFee, protocolFee);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the flash loan fee parameters. This function can only be called by the owner.\n * @param newFlashLoanFeeBPS the total fee in bps to be applied on future flash loans\n * @param newProtocolFeeShareBPS the protocol fee in bps to be applied on the total flash loan fee\n */\n function setFlashLoanFees(\n uint256 newFlashLoanFeeBPS,\n uint256 newProtocolFeeShareBPS\n ) external payable onlyOwner {\n require(\n newFlashLoanFeeBPS > 0 &&\n newFlashLoanFeeBPS <= MAX_BPS &&\n newProtocolFeeShareBPS <= MAX_BPS,\n \"fees are not in valid range\"\n );\n flashLoanFeeBPS = newFlashLoanFeeBPS;\n protocolFeeShareBPS = newProtocolFeeShareBPS;\n }\n}\n" + }, + "contracts/SwapFlashLoanV1.sol": { + "content": "// SPDX-License-Identifier: MIT WITH AGPL-3.0-only\n\npragma solidity 0.6.12;\n\nimport \"./SwapV1.sol\";\nimport \"./interfaces/IFlashLoanReceiver.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract SwapFlashLoanV1 is SwapV1 {\n // Total fee that is charged on all flashloans in BPS. Borrowers must repay the amount plus the flash loan fee.\n // This fee is split between the protocol and the pool.\n uint256 public flashLoanFeeBPS;\n // Share of the flash loan fee that goes to the protocol in BPS. A portion of each flash loan fee is allocated\n // to the protocol rather than the pool.\n uint256 public protocolFeeShareBPS;\n // Max BPS for limiting flash loan fee settings.\n uint256 public constant MAX_BPS = 10000;\n\n /*** EVENTS ***/\n event FlashLoan(\n address indexed receiver,\n uint8 tokenIndex,\n uint256 amount,\n uint256 amountFee,\n uint256 protocolFee\n );\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param _withdrawFee default withdrawFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n uint256 _withdrawFee,\n address lpTokenTargetAddress\n ) public virtual override initializer {\n SwapV1.initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n _withdrawFee,\n lpTokenTargetAddress\n );\n flashLoanFeeBPS = 8; // 8 bps\n protocolFeeShareBPS = 0; // 0 bps\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Borrow the specified token from this pool for this transaction only. This function will call\n * `IFlashLoanReceiver(receiver).executeOperation` and the `receiver` must return the full amount of the token\n * and the associated fee by the end of the callback transaction. If the conditions are not met, this call\n * is reverted.\n * @param receiver the address of the receiver of the token. This address must implement the IFlashLoanReceiver\n * interface and the callback function `executeOperation`.\n * @param token the protocol fee in bps to be applied on the total flash loan fee\n * @param amount the total amount to borrow in this transaction\n * @param params optional data to pass along to the callback function\n */\n function flashLoan(\n address receiver,\n IERC20 token,\n uint256 amount,\n bytes memory params\n ) external nonReentrant {\n uint8 tokenIndex = getTokenIndex(address(token));\n uint256 availableLiquidityBefore = token.balanceOf(address(this));\n uint256 protocolBalanceBefore = availableLiquidityBefore.sub(\n swapStorage.balances[tokenIndex]\n );\n require(\n amount > 0 && availableLiquidityBefore >= amount,\n \"invalid amount\"\n );\n\n // Calculate the additional amount of tokens the pool should end up with\n uint256 amountFee = amount.mul(flashLoanFeeBPS).div(10000);\n // Calculate the portion of the fee that will go to the protocol\n uint256 protocolFee = amountFee.mul(protocolFeeShareBPS).div(10000);\n require(amountFee > 0, \"amount is small for a flashLoan\");\n\n // Transfer the requested amount of tokens\n token.safeTransfer(receiver, amount);\n\n // Execute callback function on receiver\n IFlashLoanReceiver(receiver).executeOperation(\n address(this),\n address(token),\n amount,\n amountFee,\n params\n );\n\n uint256 availableLiquidityAfter = token.balanceOf(address(this));\n require(\n availableLiquidityAfter >= availableLiquidityBefore.add(amountFee),\n \"flashLoan fee is not met\"\n );\n\n swapStorage.balances[tokenIndex] = availableLiquidityAfter\n .sub(protocolBalanceBefore)\n .sub(protocolFee);\n emit FlashLoan(receiver, tokenIndex, amount, amountFee, protocolFee);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the flash loan fee parameters. This function can only be called by the owner.\n * @param newFlashLoanFeeBPS the total fee in bps to be applied on future flash loans\n * @param newProtocolFeeShareBPS the protocol fee in bps to be applied on the total flash loan fee\n */\n function setFlashLoanFees(\n uint256 newFlashLoanFeeBPS,\n uint256 newProtocolFeeShareBPS\n ) external onlyOwner {\n require(\n newFlashLoanFeeBPS > 0 &&\n newFlashLoanFeeBPS <= MAX_BPS &&\n newProtocolFeeShareBPS <= MAX_BPS,\n \"fees are not in valid range\"\n );\n flashLoanFeeBPS = newFlashLoanFeeBPS;\n protocolFeeShareBPS = newProtocolFeeShareBPS;\n }\n}\n" + }, + "contracts/SwapMigrator.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\npragma experimental ABIEncoderV2;\n\nimport \"./interfaces/ISwap.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\n\n/**\n * @title SwapMigrator\n * @notice This contract is responsible for migrating old USD pool liquidity to the new ones.\n * Users can use this contract to remove their liquidity from the old pools and add them to the new\n * ones with a single transaction.\n */\ncontract SwapMigrator {\n using SafeERC20 for IERC20;\n\n struct MigrationData {\n address oldPoolAddress;\n IERC20 oldPoolLPTokenAddress;\n address newPoolAddress;\n IERC20 newPoolLPTokenAddress;\n IERC20[] underlyingTokens;\n }\n\n MigrationData public usdPoolMigrationData;\n address public owner;\n\n uint256 private constant MAX_UINT256 = 2**256 - 1;\n\n /**\n * @notice Sets the storage variables and approves tokens to be used by the old and new swap contracts\n * @param usdData_ MigrationData struct with information about old and new USD pools\n * @param owner_ owner that is allowed to call the `rescue()` function\n */\n constructor(MigrationData memory usdData_, address owner_) public {\n // Approve old USD LP Token to be used by the old USD pool\n usdData_.oldPoolLPTokenAddress.approve(\n usdData_.oldPoolAddress,\n MAX_UINT256\n );\n\n // Approve USD tokens to be used by the new USD pool\n for (uint256 i = 0; i < usdData_.underlyingTokens.length; i++) {\n usdData_.underlyingTokens[i].safeApprove(\n usdData_.newPoolAddress,\n MAX_UINT256\n );\n }\n\n // Set storage variables\n usdPoolMigrationData = usdData_;\n owner = owner_;\n }\n\n /**\n * @notice Migrates old USD pool's LPToken to the new pool\n * @param amount Amount of old LPToken to migrate\n * @param minAmount Minimum amount of new LPToken to receive\n */\n function migrateUSDPool(uint256 amount, uint256 minAmount)\n external\n returns (uint256)\n {\n // Transfer old LP token from the caller\n usdPoolMigrationData.oldPoolLPTokenAddress.safeTransferFrom(\n msg.sender,\n address(this),\n amount\n );\n\n // Remove liquidity from the old pool and add them to the new pool\n uint256[] memory amounts = ISwap(usdPoolMigrationData.oldPoolAddress)\n .removeLiquidity(\n amount,\n new uint256[](usdPoolMigrationData.underlyingTokens.length),\n MAX_UINT256\n );\n uint256 mintedAmount = ISwap(usdPoolMigrationData.newPoolAddress)\n .addLiquidity(amounts, minAmount, MAX_UINT256);\n\n // Transfer new LP Token to the caller\n usdPoolMigrationData.newPoolLPTokenAddress.safeTransfer(\n msg.sender,\n mintedAmount\n );\n return mintedAmount;\n }\n\n /**\n * @notice Rescues any token that may be sent to this contract accidentally.\n * @param token Amount of old LPToken to migrate\n * @param to Minimum amount of new LPToken to receive\n */\n function rescue(IERC20 token, address to) external {\n require(msg.sender == owner, \"is not owner\");\n token.safeTransfer(to, token.balanceOf(address(this)));\n }\n}\n" + }, + "contracts/SwapUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"./AmplificationUtils.sol\";\nimport \"./LPToken.sol\";\nimport \"./MathUtils.sol\";\n\n/**\n * @title SwapUtils library\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary SwapUtils {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using MathUtils for uint256;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n\n struct Swap {\n // variables around the ramp management of A,\n // the amplification coefficient * n * (n - 1)\n // see https://www.curve.fi/stableswap-paper.pdf for details\n uint256 initialA;\n uint256 futureA;\n uint256 initialATime;\n uint256 futureATime;\n // fee calculation\n uint256 swapFee;\n uint256 adminFee;\n LPToken lpToken;\n // contract references for all tokens being pooled\n IERC20[] pooledTokens;\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\n uint256[] tokenPrecisionMultipliers;\n // the pool balance of each token, in the token's precision\n // the contract's actual token balance might differ\n uint256[] balances;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n }\n\n // Struct storing variables used in calculations in the\n // {add,remove}Liquidity functions to avoid stack too deep errors\n struct ManageLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n uint256 preciseA;\n LPToken lpToken;\n uint256 totalSupply;\n uint256[] balances;\n uint256[] multipliers;\n }\n\n // the precision all pools tokens will be converted to\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Max swap fee is 1% or 100bps of each swap\n uint256 public constant MAX_SWAP_FEE = 10**8;\n\n // Max adminFee is 100% of the swapFee\n // adminFee does not add additional fee on top of swapFee\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\n // users but only on the earnings of LPs\n uint256 public constant MAX_ADMIN_FEE = 10**10;\n\n // Constant value used as max loop limit\n uint256 private constant MAX_LOOP_LIMIT = 256;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\n return AmplificationUtils._getAPrecise(self);\n }\n\n /**\n * @notice Calculate the dy, the amount of selected token that user receives and\n * the fee of withdrawing in one token\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @param self Swap struct to read from\n * @return the amount of token user will receive\n */\n function calculateWithdrawOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256) {\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n self.lpToken.totalSupply()\n );\n return availableTokenAmount;\n }\n\n function _calculateWithdrawOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 totalSupply\n ) internal view returns (uint256, uint256) {\n uint256 dy;\n uint256 newY;\n uint256 currentY;\n\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\n self,\n tokenIndex,\n tokenAmount,\n totalSupply\n );\n\n // dy_0 (without fees)\n // dy, dy_0 - dy\n\n uint256 dySwapFee = currentY\n .sub(newY)\n .div(self.tokenPrecisionMultipliers[tokenIndex])\n .sub(dy);\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @return the d and the new y after withdrawing one token\n */\n function calculateWithdrawOneTokenDY(\n Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount,\n uint256 totalSupply\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self);\n\n require(tokenIndex < xp.length, \"Token index out of range\");\n\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\n v.preciseA = _getAPrecise(self);\n v.d0 = getD(xp, v.preciseA);\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\n for (uint256 i = 0; i < xp.length; i++) {\n uint256 xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] = xpi.sub(\n (\n (i == tokenIndex)\n ? xpi.mul(v.d1).div(v.d0).sub(v.newY)\n : xpi.sub(xpi.mul(v.d1).div(v.d0))\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\n );\n }\n\n uint256 dy = xpReduced[tokenIndex].sub(\n getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\n );\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\n\n return (dy, v.newY, xp[tokenIndex]);\n }\n\n /**\n * @notice Calculate the price of a token in the pool with given\n * precision-adjusted balances and a particular D.\n *\n * @dev This is accomplished via solving the invariant iteratively.\n * See the StableSwap paper and Curve.fi implementation for further details.\n *\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\n * x_1**2 + b*x_1 = c\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\n *\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\n * @param tokenIndex Index of token we are calculating for.\n * @param xp a precision-adjusted set of pool balances. Array should be\n * the same cardinality as the pool.\n * @param d the stableswap invariant\n * @return the price of the token, in the same precision as in xp\n */\n function getYD(\n uint256 a,\n uint8 tokenIndex,\n uint256[] memory xp,\n uint256 d\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 c = d;\n uint256 s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < numTokens; i++) {\n if (i != tokenIndex) {\n s = s.add(xp[i]);\n c = c.mul(d).div(xp[i].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n }\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\n\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\n * as the pool.\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\n * See the StableSwap paper for details\n * @return the invariant, at the precision of the pool\n */\n function getD(uint256[] memory xp, uint256 a)\n internal\n pure\n returns (uint256)\n {\n uint256 numTokens = xp.length;\n uint256 s;\n for (uint256 i = 0; i < numTokens; i++) {\n s = s.add(xp[i]);\n }\n if (s == 0) {\n return 0;\n }\n\n uint256 prevD;\n uint256 d = s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n uint256 dP = d;\n for (uint256 j = 0; j < numTokens; j++) {\n dP = dP.mul(d).div(xp[j].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // dP = dP * D * D * D * ... overflow!\n }\n prevD = d;\n d = nA\n .mul(s)\n .div(AmplificationUtils.A_PRECISION)\n .add(dP.mul(numTokens))\n .mul(d)\n .div(\n nA\n .sub(AmplificationUtils.A_PRECISION)\n .mul(d)\n .div(AmplificationUtils.A_PRECISION)\n .add(numTokens.add(1).mul(dP))\n );\n if (d.within1(prevD)) {\n return d;\n }\n }\n\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\n // function which does not rely on D.\n revert(\"D does not converge\");\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers\n ) internal pure returns (uint256[] memory) {\n uint256 numTokens = balances.length;\n require(\n numTokens == precisionMultipliers.length,\n \"Balances must match multipliers\"\n );\n uint256[] memory xp = new uint256[](numTokens);\n for (uint256 i = 0; i < numTokens; i++) {\n xp[i] = balances[i].mul(precisionMultipliers[i]);\n }\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\n return _xp(self.balances, self.tokenPrecisionMultipliers);\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice(Swap storage self)\n external\n view\n returns (uint256)\n {\n uint256 d = getD(_xp(self), _getAPrecise(self));\n LPToken lpToken = self.lpToken;\n uint256 supply = lpToken.totalSupply();\n if (supply > 0) {\n return d.mul(10**uint256(POOL_PRECISION_DECIMALS)).div(supply);\n }\n return 0;\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much TO token\n * the user should receive on swap.\n *\n * @param preciseA precise form of amplification coefficient\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param x the new total amount of FROM token\n * @param xp balances of the tokens in the pool\n * @return the amount of TO token that should remain in the pool\n */\n function getY(\n uint256 preciseA,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 x,\n uint256[] memory xp\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(\n tokenIndexFrom != tokenIndexTo,\n \"Can't compare token to itself\"\n );\n require(\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\n \"Tokens must be in pool\"\n );\n\n uint256 d = getD(xp, preciseA);\n uint256 c = d;\n uint256 s;\n uint256 nA = numTokens.mul(preciseA);\n\n uint256 _x;\n for (uint256 i = 0; i < numTokens; i++) {\n if (i == tokenIndexFrom) {\n _x = x;\n } else if (i != tokenIndexTo) {\n _x = xp[i];\n } else {\n continue;\n }\n s = s.add(_x);\n c = c.mul(d).div(_x.mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n c = c.mul(d).mul(AmplificationUtils.A_PRECISION).div(nA.mul(numTokens));\n uint256 b = s.add(d.mul(AmplificationUtils.A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n\n // iterative approximation\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Externally calculates a swap between two tokens.\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n self.balances\n );\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n * @return dyFee the associated fee\n */\n function _calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256[] memory balances\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n uint256[] memory xp = _xp(balances, multipliers);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 x = dx.mul(multipliers[tokenIndexFrom]).add(xp[tokenIndexFrom]);\n uint256 y = getY(\n _getAPrecise(self),\n tokenIndexFrom,\n tokenIndexTo,\n x,\n xp\n );\n dy = xp[tokenIndexTo].sub(y).sub(1);\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n dy = dy.sub(dyFee).div(multipliers[tokenIndexTo]);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of\n * LP tokens\n *\n * @param amount the amount of LP tokens that would to be burned on\n * withdrawal\n * @return array of amounts of tokens user will receive\n */\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\n external\n view\n returns (uint256[] memory)\n {\n return\n _calculateRemoveLiquidity(\n self.balances,\n amount,\n self.lpToken.totalSupply()\n );\n }\n\n function _calculateRemoveLiquidity(\n uint256[] memory balances,\n uint256 amount,\n uint256 totalSupply\n ) internal pure returns (uint256[] memory) {\n require(amount <= totalSupply, \"Cannot exceed total supply\");\n\n uint256[] memory amounts = new uint256[](balances.length);\n\n for (uint256 i = 0; i < balances.length; i++) {\n amounts[i] = balances[i].mul(amount).div(totalSupply);\n }\n return amounts;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n Swap storage self,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 a = _getAPrecise(self);\n uint256[] memory balances = self.balances;\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n\n uint256 d0 = getD(_xp(balances, multipliers), a);\n for (uint256 i = 0; i < balances.length; i++) {\n if (deposit) {\n balances[i] = balances[i].add(amounts[i]);\n } else {\n balances[i] = balances[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n }\n uint256 d1 = getD(_xp(balances, multipliers), a);\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return d1.sub(d0).mul(totalSupply).div(d0);\n } else {\n return d0.sub(d1).mul(totalSupply).div(d0);\n }\n }\n\n /**\n * @notice return accumulated amount of admin fees of the token with given index\n * @param self Swap struct to read from\n * @param index Index of the pooled token\n * @return admin balance in the token's precision\n */\n function getAdminBalance(Swap storage self, uint256 index)\n external\n view\n returns (uint256)\n {\n require(index < self.pooledTokens.length, \"Token index out of range\");\n return\n self.pooledTokens[index].balanceOf(address(this)).sub(\n self.balances[index]\n );\n }\n\n /**\n * @notice internal helper function to calculate fee per token multiplier used in\n * swap fee calculations\n * @param swapFee swap fee for the tokens\n * @param numTokens number of tokens pooled\n */\n function _feePerToken(uint256 swapFee, uint256 numTokens)\n internal\n pure\n returns (uint256)\n {\n return swapFee.mul(numTokens).div(numTokens.sub(1).mul(4));\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n {\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\n require(\n dx <= tokenFrom.balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n\n // Use the actual transferred amount for AMM math\n dx = tokenFrom.balanceOf(address(this)).sub(beforeBalance);\n }\n\n uint256 dy;\n uint256 dyFee;\n uint256[] memory balances = self.balances;\n (dy, dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n balances\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\n self.tokenPrecisionMultipliers[tokenIndexTo]\n );\n\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom].add(dx);\n self.balances[tokenIndexTo] = balances[tokenIndexTo].sub(dy).sub(\n dyAdminFee\n );\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\n\n return dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n Swap storage self,\n uint256[] memory amounts,\n uint256 minToMint\n ) external returns (uint256) {\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(\n amounts.length == pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n // current state\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n if (v.totalSupply != 0) {\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n }\n\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n require(\n v.totalSupply != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = pooledTokens[i].balanceOf(\n address(this)\n );\n pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\n beforeBalance\n );\n }\n\n newBalances[i] = v.balances[i].add(amounts[i]);\n }\n\n // invariant after change\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n require(v.d1 > v.d0, \"D should increase\");\n\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n uint256[] memory fees = new uint256[](pooledTokens.length);\n\n if (v.totalSupply != 0) {\n uint256 feePerToken = _feePerToken(\n self.swapFee,\n pooledTokens.length\n );\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\n fees[i] = feePerToken\n .mul(idealBalance.difference(newBalances[i]))\n .div(FEE_DENOMINATOR);\n self.balances[i] = newBalances[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n newBalances[i] = newBalances[i].sub(fees[i]);\n }\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n } else {\n // the initial depositor doesn't pay fees\n self.balances = newBalances;\n }\n\n uint256 toMint;\n if (v.totalSupply == 0) {\n toMint = v.d1;\n } else {\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n v.lpToken.mint(msg.sender, toMint);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.add(toMint)\n );\n\n return toMint;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param self Swap struct to read from and write to\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @return amounts of tokens the user received\n */\n function removeLiquidity(\n Swap storage self,\n uint256 amount,\n uint256[] calldata minAmounts\n ) external returns (uint256[] memory) {\n LPToken lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(amount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(\n minAmounts.length == pooledTokens.length,\n \"minAmounts must match poolTokens\"\n );\n\n uint256[] memory balances = self.balances;\n uint256 totalSupply = lpToken.totalSupply();\n\n uint256[] memory amounts = _calculateRemoveLiquidity(\n balances,\n amount,\n totalSupply\n );\n\n for (uint256 i = 0; i < amounts.length; i++) {\n require(amounts[i] >= minAmounts[i], \"amounts[i] < minAmounts[i]\");\n self.balances[i] = balances[i].sub(amounts[i]);\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n lpToken.burnFrom(msg.sender, amount);\n\n emit RemoveLiquidity(msg.sender, amounts, totalSupply.sub(amount));\n\n return amounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n LPToken lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(tokenIndex < pooledTokens.length, \"Token not found\");\n\n uint256 totalSupply = lpToken.totalSupply();\n\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n totalSupply\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\n );\n lpToken.burnFrom(msg.sender, tokenAmount);\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n Swap storage self,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(\n amounts.length == pooledTokens.length,\n \"Amounts should match pool tokens\"\n );\n\n require(\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\n maxBurnAmount != 0,\n \">LP.balanceOf\"\n );\n\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\n uint256[] memory fees = new uint256[](pooledTokens.length);\n {\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n balances1[i] = v.balances[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\n self.balances[i] = balances1[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n balances1[i] = balances1[i].sub(fees[i]);\n }\n\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\n }\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n tokenAmount = tokenAmount.add(1);\n\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n v.lpToken.burnFrom(msg.sender, tokenAmount);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.sub(tokenAmount)\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice withdraw all admin fees to a given address\n * @param self Swap struct to withdraw fees from\n * @param to Address to send the fees to\n */\n function withdrawAdminFees(Swap storage self, address to) external {\n IERC20[] memory pooledTokens = self.pooledTokens;\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n IERC20 token = pooledTokens[i];\n uint256 balance = token.balanceOf(address(this)).sub(\n self.balances[i]\n );\n if (balance != 0) {\n token.safeTransfer(to, balance);\n }\n }\n }\n\n /**\n * @notice Sets the admin fee\n * @dev adminFee cannot be higher than 100% of the swap fee\n * @param self Swap struct to update\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\n require(newAdminFee <= MAX_ADMIN_FEE, \"Fee is too high\");\n self.adminFee = newAdminFee;\n\n emit NewAdminFee(newAdminFee);\n }\n\n /**\n * @notice update the swap fee\n * @dev fee cannot be higher than 1% of each swap\n * @param self Swap struct to update\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\n require(newSwapFee <= MAX_SWAP_FEE, \"Fee is too high\");\n self.swapFee = newSwapFee;\n\n emit NewSwapFee(newSwapFee);\n }\n}\n" + }, + "contracts/SwapUtilsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"./AmplificationUtilsV1.sol\";\nimport \"./LPToken.sol\";\nimport \"./MathUtils.sol\";\n\n/**\n * @title SwapUtils library\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary SwapUtilsV1 {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using MathUtils for uint256;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n\n struct Swap {\n // variables around the ramp management of A,\n // the amplification coefficient * n * (n - 1)\n // see https://www.curve.fi/stableswap-paper.pdf for details\n uint256 initialA;\n uint256 futureA;\n uint256 initialATime;\n uint256 futureATime;\n // fee calculation\n uint256 swapFee;\n uint256 adminFee;\n uint256 defaultWithdrawFee;\n LPToken lpToken;\n // contract references for all tokens being pooled\n IERC20[] pooledTokens;\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\n uint256[] tokenPrecisionMultipliers;\n // the pool balance of each token, in the token's precision\n // the contract's actual token balance might differ\n uint256[] balances;\n mapping(address => uint256) depositTimestamp;\n mapping(address => uint256) withdrawFeeMultiplier;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n }\n\n // Struct storing variables used in calculations in the\n // {add,remove}Liquidity functions to avoid stack too deep errors\n struct ManageLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n uint256 preciseA;\n LPToken lpToken;\n uint256 totalSupply;\n uint256[] balances;\n uint256[] multipliers;\n }\n\n // the precision all pools tokens will be converted to\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Max swap fee is 1% or 100bps of each swap\n uint256 public constant MAX_SWAP_FEE = 10**8;\n\n // Max adminFee is 100% of the swapFee\n // adminFee does not add additional fee on top of swapFee\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\n // users but only on the earnings of LPs\n uint256 public constant MAX_ADMIN_FEE = 10**10;\n\n // Max withdrawFee is 1% of the value withdrawn\n // Fee will be redistributed to the LPs in the pool, rewarding\n // long term providers.\n uint256 public constant MAX_WITHDRAW_FEE = 10**8;\n\n // Constant value used as max loop limit\n uint256 private constant MAX_LOOP_LIMIT = 256;\n\n // Time that it should take for the withdraw fee to fully decay to 0\n uint256 public constant WITHDRAW_FEE_DECAY_TIME = 4 weeks;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n /**\n * @notice Retrieves the timestamp of last deposit made by the given address\n * @param self Swap struct to read from\n * @return timestamp of last deposit\n */\n function getDepositTimestamp(Swap storage self, address user)\n external\n view\n returns (uint256)\n {\n return self.depositTimestamp[user];\n }\n\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\n return AmplificationUtilsV1._getAPrecise(self);\n }\n\n /**\n * @notice Calculate the dy, the amount of selected token that user receives and\n * the fee of withdrawing in one token\n * @param account the address that is withdrawing\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @param self Swap struct to read from\n * @return the amount of token user will receive\n */\n function calculateWithdrawOneToken(\n Swap storage self,\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256) {\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\n self,\n account,\n tokenAmount,\n tokenIndex,\n self.lpToken.totalSupply()\n );\n return availableTokenAmount;\n }\n\n function _calculateWithdrawOneToken(\n Swap storage self,\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 totalSupply\n ) internal view returns (uint256, uint256) {\n uint256 dy;\n uint256 newY;\n uint256 currentY;\n\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\n self,\n tokenIndex,\n tokenAmount,\n totalSupply\n );\n\n // dy_0 (without fees)\n // dy, dy_0 - dy\n\n uint256 dySwapFee = currentY\n .sub(newY)\n .div(self.tokenPrecisionMultipliers[tokenIndex])\n .sub(dy);\n\n dy = dy\n .mul(\n FEE_DENOMINATOR.sub(_calculateCurrentWithdrawFee(self, account))\n )\n .div(FEE_DENOMINATOR);\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @return the d and the new y after withdrawing one token\n */\n function calculateWithdrawOneTokenDY(\n Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount,\n uint256 totalSupply\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self);\n\n require(tokenIndex < xp.length, \"Token index out of range\");\n\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\n v.preciseA = _getAPrecise(self);\n v.d0 = getD(xp, v.preciseA);\n v.d1 = v.d0.sub(tokenAmount.mul(v.d0).div(totalSupply));\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\n for (uint256 i = 0; i < xp.length; i++) {\n uint256 xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] = xpi.sub(\n (\n (i == tokenIndex)\n ? xpi.mul(v.d1).div(v.d0).sub(v.newY)\n : xpi.sub(xpi.mul(v.d1).div(v.d0))\n ).mul(v.feePerToken).div(FEE_DENOMINATOR)\n );\n }\n\n uint256 dy = xpReduced[tokenIndex].sub(\n getYD(v.preciseA, tokenIndex, xpReduced, v.d1)\n );\n dy = dy.sub(1).div(self.tokenPrecisionMultipliers[tokenIndex]);\n\n return (dy, v.newY, xp[tokenIndex]);\n }\n\n /**\n * @notice Calculate the price of a token in the pool with given\n * precision-adjusted balances and a particular D.\n *\n * @dev This is accomplished via solving the invariant iteratively.\n * See the StableSwap paper and Curve.fi implementation for further details.\n *\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\n * x_1**2 + b*x_1 = c\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\n *\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\n * @param tokenIndex Index of token we are calculating for.\n * @param xp a precision-adjusted set of pool balances. Array should be\n * the same cardinality as the pool.\n * @param d the stableswap invariant\n * @return the price of the token, in the same precision as in xp\n */\n function getYD(\n uint256 a,\n uint8 tokenIndex,\n uint256[] memory xp,\n uint256 d\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 c = d;\n uint256 s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < numTokens; i++) {\n if (i != tokenIndex) {\n s = s.add(xp[i]);\n c = c.mul(d).div(xp[i].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n }\n c = c.mul(d).mul(AmplificationUtilsV1.A_PRECISION).div(\n nA.mul(numTokens)\n );\n\n uint256 b = s.add(d.mul(AmplificationUtilsV1.A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\n * as the pool.\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\n * See the StableSwap paper for details\n * @return the invariant, at the precision of the pool\n */\n function getD(uint256[] memory xp, uint256 a)\n internal\n pure\n returns (uint256)\n {\n uint256 numTokens = xp.length;\n uint256 s;\n for (uint256 i = 0; i < numTokens; i++) {\n s = s.add(xp[i]);\n }\n if (s == 0) {\n return 0;\n }\n\n uint256 prevD;\n uint256 d = s;\n uint256 nA = a.mul(numTokens);\n\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n uint256 dP = d;\n for (uint256 j = 0; j < numTokens; j++) {\n dP = dP.mul(d).div(xp[j].mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // dP = dP * D * D * D * ... overflow!\n }\n prevD = d;\n d = nA\n .mul(s)\n .div(AmplificationUtilsV1.A_PRECISION)\n .add(dP.mul(numTokens))\n .mul(d)\n .div(\n nA\n .sub(AmplificationUtilsV1.A_PRECISION)\n .mul(d)\n .div(AmplificationUtilsV1.A_PRECISION)\n .add(numTokens.add(1).mul(dP))\n );\n if (d.within1(prevD)) {\n return d;\n }\n }\n\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\n // function which does not rely on D.\n revert(\"D does not converge\");\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers\n ) internal pure returns (uint256[] memory) {\n uint256 numTokens = balances.length;\n require(\n numTokens == precisionMultipliers.length,\n \"Balances must match multipliers\"\n );\n uint256[] memory xp = new uint256[](numTokens);\n for (uint256 i = 0; i < numTokens; i++) {\n xp[i] = balances[i].mul(precisionMultipliers[i]);\n }\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\n return _xp(self.balances, self.tokenPrecisionMultipliers);\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice(Swap storage self)\n external\n view\n returns (uint256)\n {\n uint256 d = getD(_xp(self), _getAPrecise(self));\n LPToken lpToken = self.lpToken;\n uint256 supply = lpToken.totalSupply();\n if (supply > 0) {\n return d.mul(10**uint256(POOL_PRECISION_DECIMALS)).div(supply);\n }\n return 0;\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much TO token\n * the user should receive on swap.\n *\n * @param preciseA precise form of amplification coefficient\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param x the new total amount of FROM token\n * @param xp balances of the tokens in the pool\n * @return the amount of TO token that should remain in the pool\n */\n function getY(\n uint256 preciseA,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 x,\n uint256[] memory xp\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(\n tokenIndexFrom != tokenIndexTo,\n \"Can't compare token to itself\"\n );\n require(\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\n \"Tokens must be in pool\"\n );\n\n uint256 d = getD(xp, preciseA);\n uint256 c = d;\n uint256 s;\n uint256 nA = numTokens.mul(preciseA);\n\n uint256 _x;\n for (uint256 i = 0; i < numTokens; i++) {\n if (i == tokenIndexFrom) {\n _x = x;\n } else if (i != tokenIndexTo) {\n _x = xp[i];\n } else {\n continue;\n }\n s = s.add(_x);\n c = c.mul(d).div(_x.mul(numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n c = c.mul(d).mul(AmplificationUtilsV1.A_PRECISION).div(\n nA.mul(numTokens)\n );\n uint256 b = s.add(d.mul(AmplificationUtilsV1.A_PRECISION).div(nA));\n uint256 yPrev;\n uint256 y = d;\n\n // iterative approximation\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = y.mul(y).add(c).div(y.mul(2).add(b).sub(d));\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Externally calculates a swap between two tokens.\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n self.balances\n );\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n * @return dyFee the associated fee\n */\n function _calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256[] memory balances\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n uint256[] memory xp = _xp(balances, multipliers);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 x = dx.mul(multipliers[tokenIndexFrom]).add(xp[tokenIndexFrom]);\n uint256 y = getY(\n _getAPrecise(self),\n tokenIndexFrom,\n tokenIndexTo,\n x,\n xp\n );\n dy = xp[tokenIndexTo].sub(y).sub(1);\n dyFee = dy.mul(self.swapFee).div(FEE_DENOMINATOR);\n dy = dy.sub(dyFee).div(multipliers[tokenIndexTo]);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of\n * LP tokens\n *\n * @param account the address that is removing liquidity. required for withdraw fee calculation\n * @param amount the amount of LP tokens that would to be burned on\n * withdrawal\n * @return array of amounts of tokens user will receive\n */\n function calculateRemoveLiquidity(\n Swap storage self,\n address account,\n uint256 amount\n ) external view returns (uint256[] memory) {\n return\n _calculateRemoveLiquidity(\n self,\n self.balances,\n account,\n amount,\n self.lpToken.totalSupply()\n );\n }\n\n function _calculateRemoveLiquidity(\n Swap storage self,\n uint256[] memory balances,\n address account,\n uint256 amount,\n uint256 totalSupply\n ) internal view returns (uint256[] memory) {\n require(amount <= totalSupply, \"Cannot exceed total supply\");\n\n uint256 feeAdjustedAmount = amount\n .mul(\n FEE_DENOMINATOR.sub(_calculateCurrentWithdrawFee(self, account))\n )\n .div(FEE_DENOMINATOR);\n\n uint256[] memory amounts = new uint256[](balances.length);\n\n for (uint256 i = 0; i < balances.length; i++) {\n amounts[i] = balances[i].mul(feeAdjustedAmount).div(totalSupply);\n }\n return amounts;\n }\n\n /**\n * @notice Calculate the fee that is applied when the given user withdraws.\n * Withdraw fee decays linearly over WITHDRAW_FEE_DECAY_TIME.\n * @param user address you want to calculate withdraw fee of\n * @return current withdraw fee of the user\n */\n function calculateCurrentWithdrawFee(Swap storage self, address user)\n external\n view\n returns (uint256)\n {\n return _calculateCurrentWithdrawFee(self, user);\n }\n\n function _calculateCurrentWithdrawFee(Swap storage self, address user)\n internal\n view\n returns (uint256)\n {\n uint256 endTime = self.depositTimestamp[user].add(\n WITHDRAW_FEE_DECAY_TIME\n );\n if (endTime > block.timestamp) {\n uint256 timeLeftover = endTime.sub(block.timestamp);\n return\n self\n .defaultWithdrawFee\n .mul(self.withdrawFeeMultiplier[user])\n .mul(timeLeftover)\n .div(WITHDRAW_FEE_DECAY_TIME)\n .div(FEE_DENOMINATOR);\n }\n return 0;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param account address of the account depositing or withdrawing tokens\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n Swap storage self,\n address account,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 a = _getAPrecise(self);\n uint256[] memory balances = self.balances;\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n\n uint256 d0 = getD(_xp(balances, multipliers), a);\n for (uint256 i = 0; i < balances.length; i++) {\n if (deposit) {\n balances[i] = balances[i].add(amounts[i]);\n } else {\n balances[i] = balances[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n }\n uint256 d1 = getD(_xp(balances, multipliers), a);\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return d1.sub(d0).mul(totalSupply).div(d0);\n } else {\n return\n d0.sub(d1).mul(totalSupply).div(d0).mul(FEE_DENOMINATOR).div(\n FEE_DENOMINATOR.sub(\n _calculateCurrentWithdrawFee(self, account)\n )\n );\n }\n }\n\n /**\n * @notice return accumulated amount of admin fees of the token with given index\n * @param self Swap struct to read from\n * @param index Index of the pooled token\n * @return admin balance in the token's precision\n */\n function getAdminBalance(Swap storage self, uint256 index)\n external\n view\n returns (uint256)\n {\n require(index < self.pooledTokens.length, \"Token index out of range\");\n return\n self.pooledTokens[index].balanceOf(address(this)).sub(\n self.balances[index]\n );\n }\n\n /**\n * @notice internal helper function to calculate fee per token multiplier used in\n * swap fee calculations\n * @param swapFee swap fee for the tokens\n * @param numTokens number of tokens pooled\n */\n function _feePerToken(uint256 swapFee, uint256 numTokens)\n internal\n pure\n returns (uint256)\n {\n return swapFee.mul(numTokens).div(numTokens.sub(1).mul(4));\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n {\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\n require(\n dx <= tokenFrom.balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n\n // Use the actual transferred amount for AMM math\n dx = tokenFrom.balanceOf(address(this)).sub(beforeBalance);\n }\n\n uint256 dy;\n uint256 dyFee;\n uint256[] memory balances = self.balances;\n (dy, dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n balances\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = dyFee.mul(self.adminFee).div(FEE_DENOMINATOR).div(\n self.tokenPrecisionMultipliers[tokenIndexTo]\n );\n\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom].add(dx);\n self.balances[tokenIndexTo] = balances[tokenIndexTo].sub(dy).sub(\n dyAdminFee\n );\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\n\n return dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n Swap storage self,\n uint256[] memory amounts,\n uint256 minToMint\n ) external returns (uint256) {\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(\n amounts.length == pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n // current state\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n if (v.totalSupply != 0) {\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n }\n\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n require(\n v.totalSupply != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = pooledTokens[i].balanceOf(\n address(this)\n );\n pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] = pooledTokens[i].balanceOf(address(this)).sub(\n beforeBalance\n );\n }\n\n newBalances[i] = v.balances[i].add(amounts[i]);\n }\n\n // invariant after change\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n require(v.d1 > v.d0, \"D should increase\");\n\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n uint256[] memory fees = new uint256[](pooledTokens.length);\n\n if (v.totalSupply != 0) {\n uint256 feePerToken = _feePerToken(\n self.swapFee,\n pooledTokens.length\n );\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\n fees[i] = feePerToken\n .mul(idealBalance.difference(newBalances[i]))\n .div(FEE_DENOMINATOR);\n self.balances[i] = newBalances[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n newBalances[i] = newBalances[i].sub(fees[i]);\n }\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n } else {\n // the initial depositor doesn't pay fees\n self.balances = newBalances;\n }\n\n uint256 toMint;\n if (v.totalSupply == 0) {\n toMint = v.d1;\n } else {\n toMint = v.d2.sub(v.d0).mul(v.totalSupply).div(v.d0);\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n v.lpToken.mint(msg.sender, toMint);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.add(toMint)\n );\n\n return toMint;\n }\n\n /**\n * @notice Update the withdraw fee for `user`. If the user is currently\n * not providing liquidity in the pool, sets to default value. If not, recalculate\n * the starting withdraw fee based on the last deposit's time & amount relative\n * to the new deposit.\n *\n * @param self Swap struct to read from and write to\n * @param user address of the user depositing tokens\n * @param toMint amount of pool tokens to be minted\n */\n function updateUserWithdrawFee(\n Swap storage self,\n address user,\n uint256 toMint\n ) public {\n // If token is transferred to address 0 (or burned), don't update the fee.\n if (user == address(0)) {\n return;\n }\n if (self.defaultWithdrawFee == 0) {\n // If current fee is set to 0%, set multiplier to FEE_DENOMINATOR\n self.withdrawFeeMultiplier[user] = FEE_DENOMINATOR;\n } else {\n // Otherwise, calculate appropriate discount based on last deposit amount\n uint256 currentFee = _calculateCurrentWithdrawFee(self, user);\n uint256 currentBalance = self.lpToken.balanceOf(user);\n\n // ((currentBalance * currentFee) + (toMint * defaultWithdrawFee)) * FEE_DENOMINATOR /\n // ((toMint + currentBalance) * defaultWithdrawFee)\n self.withdrawFeeMultiplier[user] = currentBalance\n .mul(currentFee)\n .add(toMint.mul(self.defaultWithdrawFee))\n .mul(FEE_DENOMINATOR)\n .div(toMint.add(currentBalance).mul(self.defaultWithdrawFee));\n }\n self.depositTimestamp[user] = block.timestamp;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param self Swap struct to read from and write to\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @return amounts of tokens the user received\n */\n function removeLiquidity(\n Swap storage self,\n uint256 amount,\n uint256[] calldata minAmounts\n ) external returns (uint256[] memory) {\n LPToken lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(amount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(\n minAmounts.length == pooledTokens.length,\n \"minAmounts must match poolTokens\"\n );\n\n uint256[] memory balances = self.balances;\n uint256 totalSupply = lpToken.totalSupply();\n\n uint256[] memory amounts = _calculateRemoveLiquidity(\n self,\n balances,\n msg.sender,\n amount,\n totalSupply\n );\n\n for (uint256 i = 0; i < amounts.length; i++) {\n require(amounts[i] >= minAmounts[i], \"amounts[i] < minAmounts[i]\");\n self.balances[i] = balances[i].sub(amounts[i]);\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n lpToken.burnFrom(msg.sender, amount);\n\n emit RemoveLiquidity(msg.sender, amounts, totalSupply.sub(amount));\n\n return amounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n LPToken lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(tokenIndex < pooledTokens.length, \"Token not found\");\n\n uint256 totalSupply = lpToken.totalSupply();\n\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\n self,\n msg.sender,\n tokenAmount,\n tokenIndex,\n totalSupply\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n self.balances[tokenIndex] = self.balances[tokenIndex].sub(\n dy.add(dyFee.mul(self.adminFee).div(FEE_DENOMINATOR))\n );\n lpToken.burnFrom(msg.sender, tokenAmount);\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n Swap storage self,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(\n amounts.length == pooledTokens.length,\n \"Amounts should match pool tokens\"\n );\n\n require(\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\n maxBurnAmount != 0,\n \">LP.balanceOf\"\n );\n\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\n uint256[] memory fees = new uint256[](pooledTokens.length);\n {\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n balances1[i] = v.balances[i].sub(\n amounts[i],\n \"Cannot withdraw more than available\"\n );\n }\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = v.d1.mul(v.balances[i]).div(v.d0);\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = feePerToken.mul(difference).div(FEE_DENOMINATOR);\n self.balances[i] = balances1[i].sub(\n fees[i].mul(self.adminFee).div(FEE_DENOMINATOR)\n );\n balances1[i] = balances1[i].sub(fees[i]);\n }\n\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\n }\n uint256 tokenAmount = v.d0.sub(v.d2).mul(v.totalSupply).div(v.d0);\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n tokenAmount = tokenAmount.add(1).mul(FEE_DENOMINATOR).div(\n FEE_DENOMINATOR.sub(_calculateCurrentWithdrawFee(self, msg.sender))\n );\n\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n v.lpToken.burnFrom(msg.sender, tokenAmount);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply.sub(tokenAmount)\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice withdraw all admin fees to a given address\n * @param self Swap struct to withdraw fees from\n * @param to Address to send the fees to\n */\n function withdrawAdminFees(Swap storage self, address to) external {\n IERC20[] memory pooledTokens = self.pooledTokens;\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n IERC20 token = pooledTokens[i];\n uint256 balance = token.balanceOf(address(this)).sub(\n self.balances[i]\n );\n if (balance != 0) {\n token.safeTransfer(to, balance);\n }\n }\n }\n\n /**\n * @notice Sets the admin fee\n * @dev adminFee cannot be higher than 100% of the swap fee\n * @param self Swap struct to update\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\n require(newAdminFee <= MAX_ADMIN_FEE, \"Fee is too high\");\n self.adminFee = newAdminFee;\n\n emit NewAdminFee(newAdminFee);\n }\n\n /**\n * @notice update the swap fee\n * @dev fee cannot be higher than 1% of each swap\n * @param self Swap struct to update\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\n require(newSwapFee <= MAX_SWAP_FEE, \"Fee is too high\");\n self.swapFee = newSwapFee;\n\n emit NewSwapFee(newSwapFee);\n }\n\n /**\n * @notice update the default withdraw fee. This also affects deposits made in the past as well.\n * @param self Swap struct to update\n * @param newWithdrawFee new withdraw fee to be applied\n */\n function setDefaultWithdrawFee(Swap storage self, uint256 newWithdrawFee)\n external\n {\n require(newWithdrawFee <= MAX_WITHDRAW_FEE, \"Fee is too high\");\n self.defaultWithdrawFee = newWithdrawFee;\n\n emit NewWithdrawFee(newWithdrawFee);\n }\n}\n" + }, + "contracts/SwapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol\";\nimport \"./OwnerPausableUpgradeable.sol\";\nimport \"./SwapUtilsV1.sol\";\nimport \"./AmplificationUtilsV1.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract SwapV1 is OwnerPausableUpgradeable, ReentrancyGuardUpgradeable {\n using SafeERC20 for IERC20;\n using SafeMath for uint256;\n using SwapUtilsV1 for SwapUtilsV1.Swap;\n using AmplificationUtilsV1 for SwapUtilsV1.Swap;\n\n // Struct storing data responsible for automatic market maker functionalities. In order to\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtilsV1.sol\n SwapUtilsV1.Swap public swapStorage;\n\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\n // getTokenIndex function also relies on this mapping to retrieve token index.\n mapping(address => uint8) private tokenIndexes;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param _withdrawFee default withdrawFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n uint256 _withdrawFee,\n address lpTokenTargetAddress\n ) public virtual initializer {\n __OwnerPausable_init();\n __ReentrancyGuard_init();\n // Check _pooledTokens and precisions parameter\n require(_pooledTokens.length > 1, \"_pooledTokens.length <= 1\");\n require(_pooledTokens.length <= 32, \"_pooledTokens.length > 32\");\n require(\n _pooledTokens.length == decimals.length,\n \"_pooledTokens decimals mismatch\"\n );\n\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\n\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\n if (i > 0) {\n // Check if index is already used. Check if 0th element is a duplicate.\n require(\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\n _pooledTokens[0] != _pooledTokens[i],\n \"Duplicate tokens\"\n );\n }\n require(\n address(_pooledTokens[i]) != address(0),\n \"The 0 address isn't an ERC-20\"\n );\n require(\n decimals[i] <= SwapUtilsV1.POOL_PRECISION_DECIMALS,\n \"Token decimals exceeds max\"\n );\n precisionMultipliers[i] =\n 10 **\n uint256(SwapUtilsV1.POOL_PRECISION_DECIMALS).sub(\n uint256(decimals[i])\n );\n tokenIndexes[address(_pooledTokens[i])] = i;\n }\n\n // Check _a, _fee, _adminFee, _withdrawFee parameters\n require(_a < AmplificationUtilsV1.MAX_A, \"_a exceeds maximum\");\n require(_fee < SwapUtilsV1.MAX_SWAP_FEE, \"_fee exceeds maximum\");\n require(\n _adminFee < SwapUtilsV1.MAX_ADMIN_FEE,\n \"_adminFee exceeds maximum\"\n );\n require(\n _withdrawFee < SwapUtilsV1.MAX_WITHDRAW_FEE,\n \"_withdrawFee exceeds maximum\"\n );\n\n // Clone and initialize a LPToken contract\n LPToken lpToken = LPToken(Clones.clone(lpTokenTargetAddress));\n require(\n lpToken.initialize(lpTokenName, lpTokenSymbol),\n \"could not init lpToken clone\"\n );\n\n // Initialize swapStorage struct\n swapStorage.lpToken = lpToken;\n swapStorage.pooledTokens = _pooledTokens;\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\n swapStorage.balances = new uint256[](_pooledTokens.length);\n swapStorage.initialA = _a.mul(AmplificationUtilsV1.A_PRECISION);\n swapStorage.futureA = _a.mul(AmplificationUtilsV1.A_PRECISION);\n // swapStorage.initialATime = 0;\n // swapStorage.futureATime = 0;\n swapStorage.swapFee = _fee;\n swapStorage.adminFee = _adminFee;\n swapStorage.defaultWithdrawFee = _withdrawFee;\n }\n\n /*** MODIFIERS ***/\n\n /**\n * @notice Modifier to check deadline against current timestamp\n * @param deadline latest timestamp to accept this transaction\n */\n modifier deadlineCheck(uint256 deadline) {\n require(block.timestamp <= deadline, \"Deadline not met\");\n _;\n }\n\n /*** VIEW FUNCTIONS ***/\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @return A parameter\n */\n function getA() external view virtual returns (uint256) {\n return swapStorage.getA();\n }\n\n /**\n * @notice Return A in its raw precision form\n * @dev See the StableSwap paper for details\n * @return A parameter in its raw precision form\n */\n function getAPrecise() external view virtual returns (uint256) {\n return swapStorage.getAPrecise();\n }\n\n /**\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) public view virtual returns (IERC20) {\n require(index < swapStorage.pooledTokens.length, \"Out of range\");\n return swapStorage.pooledTokens[index];\n }\n\n /**\n * @notice Return the index of the given token address. Reverts if no matching\n * token is found.\n * @param tokenAddress address of the token\n * @return the index of the given token address\n */\n function getTokenIndex(address tokenAddress)\n public\n view\n virtual\n returns (uint8)\n {\n uint8 index = tokenIndexes[tokenAddress];\n require(\n address(getToken(index)) == tokenAddress,\n \"Token does not exist\"\n );\n return index;\n }\n\n /**\n * @notice Return timestamp of last deposit of given address\n * @return timestamp of the last deposit made by the given address\n */\n function getDepositTimestamp(address user)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.getDepositTimestamp(user);\n }\n\n /**\n * @notice Return current balance of the pooled token at given index\n * @param index the index of the token\n * @return current balance of the pooled token at given index with token's native precision\n */\n function getTokenBalance(uint8 index)\n external\n view\n virtual\n returns (uint256)\n {\n require(index < swapStorage.pooledTokens.length, \"Index out of range\");\n return swapStorage.balances[index];\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice() external view virtual returns (uint256) {\n return swapStorage.getVirtualPrice();\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual returns (uint256) {\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param account address that is depositing or withdrawing tokens\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(\n address account,\n uint256[] calldata amounts,\n bool deposit\n ) external view virtual returns (uint256) {\n return swapStorage.calculateTokenAmount(account, amounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param account the address that is withdrawing tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(address account, uint256 amount)\n external\n view\n virtual\n returns (uint256[] memory)\n {\n return swapStorage.calculateRemoveLiquidity(account, amount);\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param account the address that is withdrawing tokens\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n address account,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view virtual returns (uint256 availableTokenAmount) {\n return\n swapStorage.calculateWithdrawOneToken(\n account,\n tokenAmount,\n tokenIndex\n );\n }\n\n /**\n * @notice Calculate the fee that is applied when the given user withdraws. The withdraw fee\n * decays linearly over period of 4 weeks. For example, depositing and withdrawing right away\n * will charge you the full amount of withdraw fee. But withdrawing after 4 weeks will charge you\n * no additional fees.\n * @dev returned value should be divided by FEE_DENOMINATOR to convert to correct decimals\n * @param user address you want to calculate withdraw fee of\n * @return current withdraw fee of the user\n */\n function calculateCurrentWithdrawFee(address user)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.calculateCurrentWithdrawFee(user);\n }\n\n /**\n * @notice This function reads the accumulated amount of admin fees of the token with given index\n * @param index Index of the pooled token\n * @return admin's token balance in the token's precision\n */\n function getAdminBalance(uint256 index)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.getAdminBalance(index);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.addLiquidity(amounts, minToMint);\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n deadlineCheck(deadline)\n returns (uint256[] memory)\n {\n return swapStorage.removeLiquidity(amount, minAmounts);\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n swapStorage.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Updates the user withdraw fee. This function can only be called by\n * the pool token. Should be used to update the withdraw fee on transfer of pool tokens.\n * Transferring your pool token will reset the 4 weeks period. If the recipient is already\n * holding some pool tokens, the withdraw fee will be discounted in respective amounts.\n * @param recipient address of the recipient of pool token\n * @param transferAmount amount of pool token to transfer\n */\n function updateUserWithdrawFee(address recipient, uint256 transferAmount)\n external\n {\n require(\n msg.sender == address(swapStorage.lpToken),\n \"Only callable by pool token\"\n );\n swapStorage.updateUserWithdrawFee(recipient, transferAmount);\n }\n\n /**\n * @notice Withdraw all admin fees to the contract owner\n */\n function withdrawAdminFees() external onlyOwner {\n swapStorage.withdrawAdminFees(owner());\n }\n\n /**\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(uint256 newAdminFee) external onlyOwner {\n swapStorage.setAdminFee(newAdminFee);\n }\n\n /**\n * @notice Update the swap fee to be applied on swaps\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(uint256 newSwapFee) external onlyOwner {\n swapStorage.setSwapFee(newSwapFee);\n }\n\n /**\n * @notice Update the withdraw fee. This fee decays linearly over 4 weeks since\n * user's last deposit.\n * @param newWithdrawFee new withdraw fee to be applied on future deposits\n */\n function setDefaultWithdrawFee(uint256 newWithdrawFee) external onlyOwner {\n swapStorage.setDefaultWithdrawFee(newWithdrawFee);\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param futureA the new A to ramp towards\n * @param futureTime timestamp when the new A should be reached\n */\n function rampA(uint256 futureA, uint256 futureTime) external onlyOwner {\n swapStorage.rampA(futureA, futureTime);\n }\n\n /**\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\n */\n function stopRampA() external onlyOwner {\n swapStorage.stopRampA();\n }\n}\n" + }, + "contracts/VirtualSwap/Bridge.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/proxy/Clones.sol\";\nimport \"synthetix/contracts/interfaces/IAddressResolver.sol\";\nimport \"synthetix/contracts/interfaces/IExchanger.sol\";\nimport \"synthetix/contracts/interfaces/IExchangeRates.sol\";\nimport \"../interfaces/ISwap.sol\";\nimport \"./SynthSwapper.sol\";\n\ncontract Proxy {\n address public target;\n}\n\ncontract Target {\n address public proxy;\n}\n\n/**\n * @title Bridge\n * @notice This contract is responsible for cross-asset swaps using the Synthetix protocol as the bridging exchange.\n * There are three types of supported cross-asset swaps, tokenToSynth, synthToToken, and tokenToToken.\n *\n * 1) tokenToSynth\n * Swaps a supported token in a saddle pool to any synthetic asset (e.g. tBTC -> sAAVE).\n *\n * 2) synthToToken\n * Swaps any synthetic asset to a suported token in a saddle pool (e.g. sDEFI -> USDC).\n *\n * 3) tokenToToken\n * Swaps a supported token in a saddle pool to one in another pool (e.g. renBTC -> DAI).\n *\n * Due to the settlement periods of synthetic assets, the users must wait until the trades can be completed.\n * Users will receive an ERC721 token that represents pending cross-asset swap. Once the waiting period is over,\n * the trades can be settled and completed by calling the `completeToSynth` or the `completeToToken` function.\n * In the cases of pending `synthToToken` or `tokenToToken` swaps, the owners of the pending swaps can also choose\n * to withdraw the bridging synthetic assets instead of completing the swap.\n */\ncontract Bridge is ERC721 {\n using SafeMath for uint256;\n using SafeERC20 for IERC20;\n\n event SynthIndex(\n address indexed swap,\n uint8 synthIndex,\n bytes32 currencyKey,\n address synthAddress\n );\n event TokenToSynth(\n address indexed requester,\n uint256 indexed itemId,\n ISwap swapPool,\n uint8 tokenFromIndex,\n uint256 tokenFromInAmount,\n bytes32 synthToKey\n );\n event SynthToToken(\n address indexed requester,\n uint256 indexed itemId,\n ISwap swapPool,\n bytes32 synthFromKey,\n uint256 synthFromInAmount,\n uint8 tokenToIndex\n );\n event TokenToToken(\n address indexed requester,\n uint256 indexed itemId,\n ISwap[2] swapPools,\n uint8 tokenFromIndex,\n uint256 tokenFromAmount,\n uint8 tokenToIndex\n );\n event Settle(\n address indexed requester,\n uint256 indexed itemId,\n IERC20 settleFrom,\n uint256 settleFromAmount,\n IERC20 settleTo,\n uint256 settleToAmount,\n bool isFinal\n );\n event Withdraw(\n address indexed requester,\n uint256 indexed itemId,\n IERC20 synth,\n uint256 synthAmount,\n bool isFinal\n );\n\n // The addresses for all Synthetix contracts can be found in the below URL.\n // https://docs.synthetix.io/addresses/#mainnet-contracts\n //\n // Since the Synthetix protocol is upgradable, we must use the proxy pairs of each contract such that\n // the composability is not broken after the protocol upgrade.\n //\n // SYNTHETIX_RESOLVER points to `ReadProxyAddressResolver` (0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2).\n // This contract is a read proxy of `AddressResolver` which is responsible for storing the addresses of the contracts\n // used by the Synthetix protocol.\n IAddressResolver public constant SYNTHETIX_RESOLVER =\n IAddressResolver(0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2);\n\n // EXCHANGER points to `Exchanger`. There is no proxy pair for this contract so we need to update this variable\n // when the protocol is upgraded. This contract is used to settle synths held by SynthSwapper.\n IExchanger public exchanger;\n\n // CONSTANTS\n\n // Available types of cross-asset swaps\n enum PendingSwapType {\n Null,\n TokenToSynth,\n SynthToToken,\n TokenToToken\n }\n\n uint256 public constant MAX_UINT256 = 2**256 - 1;\n uint8 public constant MAX_UINT8 = 2**8 - 1;\n bytes32 public constant EXCHANGE_RATES_NAME = \"ExchangeRates\";\n bytes32 public constant EXCHANGER_NAME = \"Exchanger\";\n address public immutable SYNTH_SWAPPER_MASTER;\n\n // MAPPINGS FOR STORING PENDING SETTLEMENTS\n // The below two mappings never share the same key.\n mapping(uint256 => PendingToSynthSwap) public pendingToSynthSwaps;\n mapping(uint256 => PendingToTokenSwap) public pendingToTokenSwaps;\n uint256 public pendingSwapsLength;\n mapping(uint256 => PendingSwapType) private pendingSwapType;\n\n // MAPPINGS FOR STORING SYNTH INFO\n mapping(address => SwapContractInfo) private swapContracts;\n\n // Structs holding information about pending settlements\n struct PendingToSynthSwap {\n SynthSwapper swapper;\n bytes32 synthKey;\n }\n\n struct PendingToTokenSwap {\n SynthSwapper swapper;\n bytes32 synthKey;\n ISwap swap;\n uint8 tokenToIndex;\n }\n\n struct SwapContractInfo {\n // index of the supported synth + 1\n uint8 synthIndexPlusOne;\n // address of the supported synth\n address synthAddress;\n // bytes32 key of the supported synth\n bytes32 synthKey;\n // array of tokens supported by the contract\n IERC20[] tokens;\n }\n\n /**\n * @notice Deploys this contract and initializes the master version of the SynthSwapper contract. The address to\n * the Synthetix protocol's Exchanger contract is also set on deployment.\n */\n constructor(address synthSwapperAddress)\n public\n ERC721(\"Saddle Cross-Asset Swap\", \"SaddleSynthSwap\")\n {\n SYNTH_SWAPPER_MASTER = synthSwapperAddress;\n updateExchangerCache();\n }\n\n /**\n * @notice Returns the address of the proxy contract targeting the synthetic asset with the given `synthKey`.\n * @param synthKey the currency key of the synth\n * @return address of the proxy contract\n */\n function getProxyAddressFromTargetSynthKey(bytes32 synthKey)\n public\n view\n returns (IERC20)\n {\n return IERC20(Target(SYNTHETIX_RESOLVER.getSynth(synthKey)).proxy());\n }\n\n /**\n * @notice Returns various information of a pending swap represented by the given `itemId`. Information includes\n * the type of the pending swap, the number of seconds left until it can be settled, the address and the balance\n * of the synth this swap currently holds, and the address of the destination token.\n * @param itemId ID of the pending swap\n * @return swapType the type of the pending virtual swap,\n * secsLeft number of seconds left until this swap can be settled,\n * synth address of the synth this swap uses,\n * synthBalance amount of the synth this swap holds,\n * tokenTo the address of the destination token\n */\n function getPendingSwapInfo(uint256 itemId)\n external\n view\n returns (\n PendingSwapType swapType,\n uint256 secsLeft,\n address synth,\n uint256 synthBalance,\n address tokenTo\n )\n {\n swapType = pendingSwapType[itemId];\n require(swapType != PendingSwapType.Null, \"invalid itemId\");\n\n SynthSwapper synthSwapper;\n bytes32 synthKey;\n\n if (swapType == PendingSwapType.TokenToSynth) {\n synthSwapper = pendingToSynthSwaps[itemId].swapper;\n synthKey = pendingToSynthSwaps[itemId].synthKey;\n synth = address(getProxyAddressFromTargetSynthKey(synthKey));\n tokenTo = synth;\n } else {\n PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[\n itemId\n ];\n synthSwapper = pendingToTokenSwap.swapper;\n synthKey = pendingToTokenSwap.synthKey;\n synth = address(getProxyAddressFromTargetSynthKey(synthKey));\n tokenTo = address(\n swapContracts[address(pendingToTokenSwap.swap)].tokens[\n pendingToTokenSwap.tokenToIndex\n ]\n );\n }\n\n secsLeft = exchanger.maxSecsLeftInWaitingPeriod(\n address(synthSwapper),\n synthKey\n );\n synthBalance = IERC20(synth).balanceOf(address(synthSwapper));\n }\n\n // Settles the synth only.\n function _settle(address synthOwner, bytes32 synthKey) internal {\n // Settle synth\n exchanger.settle(synthOwner, synthKey);\n }\n\n /**\n * @notice Settles and withdraws the synthetic asset without swapping it to a token in a Saddle pool. Only the owner\n * of the ERC721 token of `itemId` can call this function. Reverts if the given `itemId` does not represent a\n * `synthToToken` or a `tokenToToken` swap.\n * @param itemId ID of the pending swap\n * @param amount the amount of the synth to withdraw\n */\n function withdraw(uint256 itemId, uint256 amount) external {\n address nftOwner = ownerOf(itemId);\n require(nftOwner == msg.sender, \"not owner\");\n require(\n pendingSwapType[itemId] > PendingSwapType.TokenToSynth,\n \"invalid itemId\"\n );\n PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[\n itemId\n ];\n _settle(\n address(pendingToTokenSwap.swapper),\n pendingToTokenSwap.synthKey\n );\n\n IERC20 synth = getProxyAddressFromTargetSynthKey(\n pendingToTokenSwap.synthKey\n );\n bool shouldDestroy;\n\n if (amount >= synth.balanceOf(address(pendingToTokenSwap.swapper))) {\n _burn(itemId);\n delete pendingToTokenSwaps[itemId];\n delete pendingSwapType[itemId];\n shouldDestroy = true;\n }\n\n pendingToTokenSwap.swapper.withdraw(\n synth,\n nftOwner,\n amount,\n shouldDestroy\n );\n emit Withdraw(msg.sender, itemId, synth, amount, shouldDestroy);\n }\n\n /**\n * @notice Completes the pending `tokenToSynth` swap by settling and withdrawing the synthetic asset.\n * Reverts if the given `itemId` does not represent a `tokenToSynth` swap.\n * @param itemId ERC721 token ID representing a pending `tokenToSynth` swap\n */\n function completeToSynth(uint256 itemId) external {\n address nftOwner = ownerOf(itemId);\n require(nftOwner == msg.sender, \"not owner\");\n require(\n pendingSwapType[itemId] == PendingSwapType.TokenToSynth,\n \"invalid itemId\"\n );\n\n PendingToSynthSwap memory pendingToSynthSwap = pendingToSynthSwaps[\n itemId\n ];\n _settle(\n address(pendingToSynthSwap.swapper),\n pendingToSynthSwap.synthKey\n );\n\n IERC20 synth = getProxyAddressFromTargetSynthKey(\n pendingToSynthSwap.synthKey\n );\n\n // Burn the corresponding ERC721 token and delete storage for gas\n _burn(itemId);\n delete pendingToTokenSwaps[itemId];\n delete pendingSwapType[itemId];\n\n // After settlement, withdraw the synth and send it to the recipient\n uint256 synthBalance = synth.balanceOf(\n address(pendingToSynthSwap.swapper)\n );\n pendingToSynthSwap.swapper.withdraw(\n synth,\n nftOwner,\n synthBalance,\n true\n );\n\n emit Settle(\n msg.sender,\n itemId,\n synth,\n synthBalance,\n synth,\n synthBalance,\n true\n );\n }\n\n /**\n * @notice Calculates the expected amount of the token to receive on calling `completeToToken()` with\n * the given `swapAmount`.\n * @param itemId ERC721 token ID representing a pending `SynthToToken` or `TokenToToken` swap\n * @param swapAmount the amount of bridging synth to swap from\n * @return expected amount of the token the user will receive\n */\n function calcCompleteToToken(uint256 itemId, uint256 swapAmount)\n external\n view\n returns (uint256)\n {\n require(\n pendingSwapType[itemId] > PendingSwapType.TokenToSynth,\n \"invalid itemId\"\n );\n\n PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[\n itemId\n ];\n return\n pendingToTokenSwap.swap.calculateSwap(\n getSynthIndex(pendingToTokenSwap.swap),\n pendingToTokenSwap.tokenToIndex,\n swapAmount\n );\n }\n\n /**\n * @notice Completes the pending `SynthToToken` or `TokenToToken` swap by settling the bridging synth and swapping\n * it to the desired token. Only the owners of the pending swaps can call this function.\n * @param itemId ERC721 token ID representing a pending `SynthToToken` or `TokenToToken` swap\n * @param swapAmount the amount of bridging synth to swap from\n * @param minAmount the minimum amount of the token to receive - reverts if this amount is not reached\n * @param deadline the timestamp representing the deadline for this transaction - reverts if deadline is not met\n */\n function completeToToken(\n uint256 itemId,\n uint256 swapAmount,\n uint256 minAmount,\n uint256 deadline\n ) external {\n require(swapAmount != 0, \"amount must be greater than 0\");\n address nftOwner = ownerOf(itemId);\n require(msg.sender == nftOwner, \"must own itemId\");\n require(\n pendingSwapType[itemId] > PendingSwapType.TokenToSynth,\n \"invalid itemId\"\n );\n\n PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[\n itemId\n ];\n\n _settle(\n address(pendingToTokenSwap.swapper),\n pendingToTokenSwap.synthKey\n );\n IERC20 synth = getProxyAddressFromTargetSynthKey(\n pendingToTokenSwap.synthKey\n );\n bool shouldDestroyClone;\n\n if (\n swapAmount >= synth.balanceOf(address(pendingToTokenSwap.swapper))\n ) {\n _burn(itemId);\n delete pendingToTokenSwaps[itemId];\n delete pendingSwapType[itemId];\n shouldDestroyClone = true;\n }\n\n // Try swapping the synth to the desired token via the stored swap pool contract\n // If the external call succeeds, send the token to the owner of token with itemId.\n (IERC20 tokenTo, uint256 amountOut) = pendingToTokenSwap\n .swapper\n .swapSynthToToken(\n pendingToTokenSwap.swap,\n synth,\n getSynthIndex(pendingToTokenSwap.swap),\n pendingToTokenSwap.tokenToIndex,\n swapAmount,\n minAmount,\n deadline,\n nftOwner\n );\n\n if (shouldDestroyClone) {\n pendingToTokenSwap.swapper.destroy();\n }\n\n emit Settle(\n msg.sender,\n itemId,\n synth,\n swapAmount,\n tokenTo,\n amountOut,\n shouldDestroyClone\n );\n }\n\n // Add the given pending synth settlement struct to the list\n function _addToPendingSynthSwapList(\n PendingToSynthSwap memory pendingToSynthSwap\n ) internal returns (uint256) {\n require(\n pendingSwapsLength < MAX_UINT256,\n \"pendingSwapsLength reached max size\"\n );\n pendingToSynthSwaps[pendingSwapsLength] = pendingToSynthSwap;\n return pendingSwapsLength++;\n }\n\n // Add the given pending synth to token settlement struct to the list\n function _addToPendingSynthToTokenSwapList(\n PendingToTokenSwap memory pendingToTokenSwap\n ) internal returns (uint256) {\n require(\n pendingSwapsLength < MAX_UINT256,\n \"pendingSwapsLength reached max size\"\n );\n pendingToTokenSwaps[pendingSwapsLength] = pendingToTokenSwap;\n return pendingSwapsLength++;\n }\n\n /**\n * @notice Calculates the expected amount of the desired synthetic asset the caller will receive after completing\n * a `TokenToSynth` swap with the given parameters. This calculation does not consider the settlement periods.\n * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth\n * @param tokenFromIndex the index of the token to swap from\n * @param synthOutKey the currency key of the desired synthetic asset\n * @param tokenInAmount the amount of the token to swap form\n * @return the expected amount of the desired synth\n */\n function calcTokenToSynth(\n ISwap swap,\n uint8 tokenFromIndex,\n bytes32 synthOutKey,\n uint256 tokenInAmount\n ) external view returns (uint256) {\n uint8 mediumSynthIndex = getSynthIndex(swap);\n uint256 expectedMediumSynthAmount = swap.calculateSwap(\n tokenFromIndex,\n mediumSynthIndex,\n tokenInAmount\n );\n bytes32 mediumSynthKey = getSynthKey(swap);\n\n IExchangeRates exchangeRates = IExchangeRates(\n SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)\n );\n return\n exchangeRates.effectiveValue(\n mediumSynthKey,\n expectedMediumSynthAmount,\n synthOutKey\n );\n }\n\n /**\n * @notice Initiates a cross-asset swap from a token supported in the `swap` pool to any synthetic asset.\n * The caller will receive an ERC721 token representing their ownership of the pending cross-asset swap.\n * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth\n * @param tokenFromIndex the index of the token to swap from\n * @param synthOutKey the currency key of the desired synthetic asset\n * @param tokenInAmount the amount of the token to swap form\n * @param minAmount the amount of the token to swap form\n * @return ID of the ERC721 token sent to the caller\n */\n function tokenToSynth(\n ISwap swap,\n uint8 tokenFromIndex,\n bytes32 synthOutKey,\n uint256 tokenInAmount,\n uint256 minAmount\n ) external returns (uint256) {\n require(tokenInAmount != 0, \"amount must be greater than 0\");\n // Create a SynthSwapper clone\n SynthSwapper synthSwapper = SynthSwapper(\n Clones.clone(SYNTH_SWAPPER_MASTER)\n );\n synthSwapper.initialize();\n\n // Add the synthswapper to the pending settlement list\n uint256 itemId = _addToPendingSynthSwapList(\n PendingToSynthSwap(synthSwapper, synthOutKey)\n );\n pendingSwapType[itemId] = PendingSwapType.TokenToSynth;\n\n // Mint an ERC721 token that represents ownership of the pending synth settlement to msg.sender\n _mint(msg.sender, itemId);\n\n // Transfer token from msg.sender\n IERC20 tokenFrom = swapContracts[address(swap)].tokens[tokenFromIndex]; // revert when token not found in swap pool\n tokenFrom.safeTransferFrom(msg.sender, address(this), tokenInAmount);\n tokenInAmount = tokenFrom.balanceOf(address(this));\n\n // Swap the synth to the medium synth\n uint256 mediumSynthAmount = swap.swap(\n tokenFromIndex,\n getSynthIndex(swap),\n tokenInAmount,\n 0,\n block.timestamp\n );\n\n // Swap synths via Synthetix network\n IERC20(getSynthAddress(swap)).safeTransfer(\n address(synthSwapper),\n mediumSynthAmount\n );\n require(\n synthSwapper.swapSynth(\n getSynthKey(swap),\n mediumSynthAmount,\n synthOutKey\n ) >= minAmount,\n \"minAmount not reached\"\n );\n\n // Emit TokenToSynth event with relevant data\n emit TokenToSynth(\n msg.sender,\n itemId,\n swap,\n tokenFromIndex,\n tokenInAmount,\n synthOutKey\n );\n\n return (itemId);\n }\n\n /**\n * @notice Calculates the expected amount of the desired token the caller will receive after completing\n * a `SynthToToken` swap with the given parameters. This calculation does not consider the settlement periods or\n * any potential changes of the `swap` pool composition.\n * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth\n * @param synthInKey the currency key of the synth to swap from\n * @param tokenToIndex the index of the token to swap to\n * @param synthInAmount the amount of the synth to swap form\n * @return the expected amount of the bridging synth and the expected amount of the desired token\n */\n function calcSynthToToken(\n ISwap swap,\n bytes32 synthInKey,\n uint8 tokenToIndex,\n uint256 synthInAmount\n ) external view returns (uint256, uint256) {\n IExchangeRates exchangeRates = IExchangeRates(\n SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)\n );\n\n uint8 mediumSynthIndex = getSynthIndex(swap);\n bytes32 mediumSynthKey = getSynthKey(swap);\n require(synthInKey != mediumSynthKey, \"use normal swap\");\n\n uint256 expectedMediumSynthAmount = exchangeRates.effectiveValue(\n synthInKey,\n synthInAmount,\n mediumSynthKey\n );\n\n return (\n expectedMediumSynthAmount,\n swap.calculateSwap(\n mediumSynthIndex,\n tokenToIndex,\n expectedMediumSynthAmount\n )\n );\n }\n\n /**\n * @notice Initiates a cross-asset swap from a synthetic asset to a supported token. The caller will receive\n * an ERC721 token representing their ownership of the pending cross-asset swap.\n * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth\n * @param synthInKey the currency key of the synth to swap from\n * @param tokenToIndex the index of the token to swap to\n * @param synthInAmount the amount of the synth to swap form\n * @param minMediumSynthAmount the minimum amount of the bridging synth at pre-settlement stage\n * @return the ID of the ERC721 token sent to the caller\n */\n function synthToToken(\n ISwap swap,\n bytes32 synthInKey,\n uint8 tokenToIndex,\n uint256 synthInAmount,\n uint256 minMediumSynthAmount\n ) external returns (uint256) {\n require(synthInAmount != 0, \"amount must be greater than 0\");\n bytes32 mediumSynthKey = getSynthKey(swap);\n require(\n synthInKey != mediumSynthKey,\n \"synth is supported via normal swap\"\n );\n\n // Create a SynthSwapper clone\n SynthSwapper synthSwapper = SynthSwapper(\n Clones.clone(SYNTH_SWAPPER_MASTER)\n );\n synthSwapper.initialize();\n\n // Add the synthswapper to the pending synth to token settlement list\n uint256 itemId = _addToPendingSynthToTokenSwapList(\n PendingToTokenSwap(synthSwapper, mediumSynthKey, swap, tokenToIndex)\n );\n pendingSwapType[itemId] = PendingSwapType.SynthToToken;\n\n // Mint an ERC721 token that represents ownership of the pending synth to token settlement to msg.sender\n _mint(msg.sender, itemId);\n\n // Receive synth from the user and swap it to another synth\n IERC20 synthFrom = getProxyAddressFromTargetSynthKey(synthInKey);\n synthFrom.safeTransferFrom(msg.sender, address(this), synthInAmount);\n synthFrom.safeTransfer(address(synthSwapper), synthInAmount);\n require(\n synthSwapper.swapSynth(synthInKey, synthInAmount, mediumSynthKey) >=\n minMediumSynthAmount,\n \"minMediumSynthAmount not reached\"\n );\n\n // Emit SynthToToken event with relevant data\n emit SynthToToken(\n msg.sender,\n itemId,\n swap,\n synthInKey,\n synthInAmount,\n tokenToIndex\n );\n\n return (itemId);\n }\n\n /**\n * @notice Calculates the expected amount of the desired token the caller will receive after completing\n * a `TokenToToken` swap with the given parameters. This calculation does not consider the settlement periods or\n * any potential changes of the pool compositions.\n * @param swaps the addresses of the two Saddle pools used to do the cross-asset swap\n * @param tokenFromIndex the index of the token in the first `swaps` pool to swap from\n * @param tokenToIndex the index of the token in the second `swaps` pool to swap to\n * @param tokenFromAmount the amount of the token to swap from\n * @return the expected amount of bridging synth at pre-settlement stage and the expected amount of the desired\n * token\n */\n function calcTokenToToken(\n ISwap[2] calldata swaps,\n uint8 tokenFromIndex,\n uint8 tokenToIndex,\n uint256 tokenFromAmount\n ) external view returns (uint256, uint256) {\n IExchangeRates exchangeRates = IExchangeRates(\n SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)\n );\n\n uint256 firstSynthAmount = swaps[0].calculateSwap(\n tokenFromIndex,\n getSynthIndex(swaps[0]),\n tokenFromAmount\n );\n\n uint256 mediumSynthAmount = exchangeRates.effectiveValue(\n getSynthKey(swaps[0]),\n firstSynthAmount,\n getSynthKey(swaps[1])\n );\n\n return (\n mediumSynthAmount,\n swaps[1].calculateSwap(\n getSynthIndex(swaps[1]),\n tokenToIndex,\n mediumSynthAmount\n )\n );\n }\n\n /**\n * @notice Initiates a cross-asset swap from a token in one Saddle pool to one in another. The caller will receive\n * an ERC721 token representing their ownership of the pending cross-asset swap.\n * @param swaps the addresses of the two Saddle pools used to do the cross-asset swap\n * @param tokenFromIndex the index of the token in the first `swaps` pool to swap from\n * @param tokenToIndex the index of the token in the second `swaps` pool to swap to\n * @param tokenFromAmount the amount of the token to swap from\n * @param minMediumSynthAmount the minimum amount of the bridging synth at pre-settlement stage\n * @return the ID of the ERC721 token sent to the caller\n */\n function tokenToToken(\n ISwap[2] calldata swaps,\n uint8 tokenFromIndex,\n uint8 tokenToIndex,\n uint256 tokenFromAmount,\n uint256 minMediumSynthAmount\n ) external returns (uint256) {\n // Create a SynthSwapper clone\n require(tokenFromAmount != 0, \"amount must be greater than 0\");\n SynthSwapper synthSwapper = SynthSwapper(\n Clones.clone(SYNTH_SWAPPER_MASTER)\n );\n synthSwapper.initialize();\n bytes32 mediumSynthKey = getSynthKey(swaps[1]);\n\n // Add the synthswapper to the pending synth to token settlement list\n uint256 itemId = _addToPendingSynthToTokenSwapList(\n PendingToTokenSwap(\n synthSwapper,\n mediumSynthKey,\n swaps[1],\n tokenToIndex\n )\n );\n pendingSwapType[itemId] = PendingSwapType.TokenToToken;\n\n // Mint an ERC721 token that represents ownership of the pending swap to msg.sender\n _mint(msg.sender, itemId);\n\n // Receive token from the user\n ISwap swap = swaps[0];\n {\n IERC20 tokenFrom = swapContracts[address(swap)].tokens[\n tokenFromIndex\n ];\n tokenFrom.safeTransferFrom(\n msg.sender,\n address(this),\n tokenFromAmount\n );\n }\n\n uint256 firstSynthAmount = swap.swap(\n tokenFromIndex,\n getSynthIndex(swap),\n tokenFromAmount,\n 0,\n block.timestamp\n );\n\n // Swap the synth to another synth\n IERC20(getSynthAddress(swap)).safeTransfer(\n address(synthSwapper),\n firstSynthAmount\n );\n require(\n synthSwapper.swapSynth(\n getSynthKey(swap),\n firstSynthAmount,\n mediumSynthKey\n ) >= minMediumSynthAmount,\n \"minMediumSynthAmount not reached\"\n );\n\n // Emit TokenToToken event with relevant data\n emit TokenToToken(\n msg.sender,\n itemId,\n swaps,\n tokenFromIndex,\n tokenFromAmount,\n tokenToIndex\n );\n\n return (itemId);\n }\n\n /**\n * @notice Registers the index and the address of the supported synth from the given `swap` pool. The matching currency key must\n * be supplied for a successful registration.\n * @param swap the address of the pool that contains the synth\n * @param synthIndex the index of the supported synth in the given `swap` pool\n * @param currencyKey the currency key of the synth in bytes32 form\n */\n function setSynthIndex(\n ISwap swap,\n uint8 synthIndex,\n bytes32 currencyKey\n ) external {\n require(synthIndex < MAX_UINT8, \"index is too large\");\n SwapContractInfo storage swapContractInfo = swapContracts[\n address(swap)\n ];\n // Check if the pool has already been added\n require(swapContractInfo.synthIndexPlusOne == 0, \"Pool already added\");\n // Ensure the synth with the same currency key exists at the given `synthIndex`\n IERC20 synth = swap.getToken(synthIndex);\n require(\n ISynth(Proxy(address(synth)).target()).currencyKey() == currencyKey,\n \"currencyKey does not match\"\n );\n swapContractInfo.synthIndexPlusOne = synthIndex + 1;\n swapContractInfo.synthAddress = address(synth);\n swapContractInfo.synthKey = currencyKey;\n swapContractInfo.tokens = new IERC20[](0);\n\n for (uint8 i = 0; i < MAX_UINT8; i++) {\n IERC20 token;\n if (i == synthIndex) {\n token = synth;\n } else {\n try swap.getToken(i) returns (IERC20 token_) {\n token = token_;\n } catch {\n break;\n }\n }\n swapContractInfo.tokens.push(token);\n token.safeApprove(address(swap), MAX_UINT256);\n }\n\n emit SynthIndex(address(swap), synthIndex, currencyKey, address(synth));\n }\n\n /**\n * @notice Returns the index of the supported synth in the given `swap` pool. Reverts if the `swap` pool\n * is not registered.\n * @param swap the address of the pool that contains the synth\n * @return the index of the supported synth\n */\n function getSynthIndex(ISwap swap) public view returns (uint8) {\n uint8 synthIndexPlusOne = swapContracts[address(swap)]\n .synthIndexPlusOne;\n require(synthIndexPlusOne > 0, \"synth index not found for given pool\");\n return synthIndexPlusOne - 1;\n }\n\n /**\n * @notice Returns the address of the supported synth in the given `swap` pool. Reverts if the `swap` pool\n * is not registered.\n * @param swap the address of the pool that contains the synth\n * @return the address of the supported synth\n */\n function getSynthAddress(ISwap swap) public view returns (address) {\n address synthAddress = swapContracts[address(swap)].synthAddress;\n require(\n synthAddress != address(0),\n \"synth addr not found for given pool\"\n );\n return synthAddress;\n }\n\n /**\n * @notice Returns the currency key of the supported synth in the given `swap` pool. Reverts if the `swap` pool\n * is not registered.\n * @param swap the address of the pool that contains the synth\n * @return the currency key of the supported synth\n */\n function getSynthKey(ISwap swap) public view returns (bytes32) {\n bytes32 synthKey = swapContracts[address(swap)].synthKey;\n require(synthKey != 0x0, \"synth key not found for given pool\");\n return synthKey;\n }\n\n /**\n * @notice Updates the stored address of the `EXCHANGER` contract. When the Synthetix team upgrades their protocol,\n * a new Exchanger contract is deployed. This function manually updates the stored address.\n */\n function updateExchangerCache() public {\n exchanger = IExchanger(SYNTHETIX_RESOLVER.getAddress(EXCHANGER_NAME));\n }\n}\n" + }, + "contracts/VirtualSwap/SynthSwapper.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.6.12;\n\nimport \"synthetix/contracts/interfaces/ISynthetix.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"../interfaces/ISwap.sol\";\n\n/**\n * @title SynthSwapper\n * @notice Replacement of Virtual Synths in favor of gas savings. Allows swapping synths via the Synthetix protocol\n * or Saddle's pools. The `Bridge.sol` contract will deploy minimal clones of this contract upon initiating\n * any cross-asset swaps.\n */\ncontract SynthSwapper is Initializable {\n using SafeERC20 for IERC20;\n\n address payable owner;\n // SYNTHETIX points to `ProxyERC20` (0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F).\n // This contract is a proxy of `Synthetix` and is used to exchange synths.\n ISynthetix public constant SYNTHETIX =\n ISynthetix(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F);\n // \"SADDLE\" in bytes32 form\n bytes32 public constant TRACKING =\n 0x534144444c450000000000000000000000000000000000000000000000000000;\n\n /**\n * @notice Initializes the contract when deploying this directly. This prevents\n * others from calling initialize() on the target contract and setting themself as the owner.\n */\n constructor() public {\n initialize();\n }\n\n /**\n * @notice This modifier checks if the caller is the owner\n */\n modifier onlyOwner() {\n require(msg.sender == owner, \"is not owner\");\n _;\n }\n\n /**\n * @notice Sets the `owner` as the caller of this function\n */\n function initialize() public initializer {\n require(owner == address(0), \"owner already set\");\n owner = msg.sender;\n }\n\n /**\n * @notice Swaps the synth to another synth via the Synthetix protocol.\n * @param sourceKey currency key of the source synth\n * @param synthAmount amount of the synth to swap\n * @param destKey currency key of the destination synth\n * @return amount of the destination synth received\n */\n function swapSynth(\n bytes32 sourceKey,\n uint256 synthAmount,\n bytes32 destKey\n ) external onlyOwner returns (uint256) {\n return\n SYNTHETIX.exchangeWithTracking(\n sourceKey,\n synthAmount,\n destKey,\n msg.sender,\n TRACKING\n );\n }\n\n /**\n * @notice Approves the given `tokenFrom` and swaps it to another token via the given `swap` pool.\n * @param swap the address of a pool to swap through\n * @param tokenFrom the address of the stored synth\n * @param tokenFromIndex the index of the token to swap from\n * @param tokenToIndex the token the user wants to swap to\n * @param tokenFromAmount the amount of the token to swap\n * @param minAmount the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n * @param recipient the address of the recipient\n */\n function swapSynthToToken(\n ISwap swap,\n IERC20 tokenFrom,\n uint8 tokenFromIndex,\n uint8 tokenToIndex,\n uint256 tokenFromAmount,\n uint256 minAmount,\n uint256 deadline,\n address recipient\n ) external onlyOwner returns (IERC20, uint256) {\n tokenFrom.approve(address(swap), tokenFromAmount);\n swap.swap(\n tokenFromIndex,\n tokenToIndex,\n tokenFromAmount,\n minAmount,\n deadline\n );\n IERC20 tokenTo = swap.getToken(tokenToIndex);\n uint256 balance = tokenTo.balanceOf(address(this));\n tokenTo.safeTransfer(recipient, balance);\n return (tokenTo, balance);\n }\n\n /**\n * @notice Withdraws the given amount of `token` to the `recipient`.\n * @param token the address of the token to withdraw\n * @param recipient the address of the account to receive the token\n * @param withdrawAmount the amount of the token to withdraw\n * @param shouldDestroy whether this contract should be destroyed after this call\n */\n function withdraw(\n IERC20 token,\n address recipient,\n uint256 withdrawAmount,\n bool shouldDestroy\n ) external onlyOwner {\n token.safeTransfer(recipient, withdrawAmount);\n if (shouldDestroy) {\n _destroy();\n }\n }\n\n /**\n * @notice Destroys this contract. Only owner can call this function.\n */\n function destroy() external onlyOwner {\n _destroy();\n }\n\n function _destroy() internal {\n selfdestruct(msg.sender);\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" + }, + "synthetix/contracts/interfaces/IAddressResolver.sol": { + "content": "pragma solidity >=0.4.24;\n\n// https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver\ninterface IAddressResolver {\n function getAddress(bytes32 name) external view returns (address);\n\n function getSynth(bytes32 key) external view returns (address);\n\n function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);\n}\n" + }, + "synthetix/contracts/interfaces/IExchanger.sol": { + "content": "pragma solidity >=0.4.24;\n\nimport \"./IVirtualSynth.sol\";\n\n// https://docs.synthetix.io/contracts/source/interfaces/iexchanger\ninterface IExchanger {\n // Views\n function calculateAmountAfterSettlement(\n address from,\n bytes32 currencyKey,\n uint amount,\n uint refunded\n ) external view returns (uint amountAfterSettlement);\n\n function isSynthRateInvalid(bytes32 currencyKey) external view returns (bool);\n\n function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);\n\n function settlementOwing(address account, bytes32 currencyKey)\n external\n view\n returns (\n uint reclaimAmount,\n uint rebateAmount,\n uint numEntries\n );\n\n function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool);\n\n function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)\n external\n view\n returns (uint exchangeFeeRate);\n\n function getAmountsForExchange(\n uint sourceAmount,\n bytes32 sourceCurrencyKey,\n bytes32 destinationCurrencyKey\n )\n external\n view\n returns (\n uint amountReceived,\n uint fee,\n uint exchangeFeeRate\n );\n\n function priceDeviationThresholdFactor() external view returns (uint);\n\n function waitingPeriodSecs() external view returns (uint);\n\n // Mutative functions\n function exchange(\n address exchangeForAddress,\n address from,\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n address destinationAddress,\n bool virtualSynth,\n address rewardAddress,\n bytes32 trackingCode\n ) external returns (uint amountReceived, IVirtualSynth vSynth);\n\n function exchangeAtomically(\n address from,\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n address destinationAddress,\n bytes32 trackingCode\n ) external returns (uint amountReceived);\n\n function settle(address from, bytes32 currencyKey)\n external\n returns (\n uint reclaimed,\n uint refunded,\n uint numEntries\n );\n\n function resetLastExchangeRate(bytes32[] calldata currencyKeys) external;\n\n function suspendSynthWithInvalidRate(bytes32 currencyKey) external;\n}\n" + }, + "synthetix/contracts/interfaces/IExchangeRates.sol": { + "content": "pragma solidity >=0.4.24;\n\n// https://docs.synthetix.io/contracts/source/interfaces/iexchangerates\ninterface IExchangeRates {\n // Structs\n struct RateAndUpdatedTime {\n uint216 rate;\n uint40 time;\n }\n\n // Views\n function aggregators(bytes32 currencyKey) external view returns (address);\n\n function aggregatorWarningFlags() external view returns (address);\n\n function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool);\n\n function currentRoundForRate(bytes32 currencyKey) external view returns (uint);\n\n function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory);\n\n function effectiveValue(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey\n ) external view returns (uint value);\n\n function effectiveValueAndRates(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey\n )\n external\n view\n returns (\n uint value,\n uint sourceRate,\n uint destinationRate\n );\n\n function effectiveAtomicValueAndRates(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey\n )\n external\n view\n returns (\n uint value,\n uint systemValue,\n uint systemSourceRate,\n uint systemDestinationRate\n );\n\n function effectiveValueAtRound(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n uint roundIdForSrc,\n uint roundIdForDest\n ) external view returns (uint value);\n\n function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);\n\n function getLastRoundIdBeforeElapsedSecs(\n bytes32 currencyKey,\n uint startingRoundId,\n uint startingTimestamp,\n uint timediff\n ) external view returns (uint);\n\n function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);\n\n function oracle() external view returns (address);\n\n function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time);\n\n function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);\n\n function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);\n\n function rateForCurrency(bytes32 currencyKey) external view returns (uint);\n\n function rateIsFlagged(bytes32 currencyKey) external view returns (bool);\n\n function rateIsInvalid(bytes32 currencyKey) external view returns (bool);\n\n function rateIsStale(bytes32 currencyKey) external view returns (bool);\n\n function rateStalePeriod() external view returns (uint);\n\n function ratesAndUpdatedTimeForCurrencyLastNRounds(bytes32 currencyKey, uint numRounds)\n external\n view\n returns (uint[] memory rates, uint[] memory times);\n\n function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys)\n external\n view\n returns (uint[] memory rates, bool anyRateInvalid);\n\n function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);\n\n function synthTooVolatileForAtomicExchange(bytes32 currencyKey) external view returns (bool);\n}\n" + }, + "synthetix/contracts/interfaces/ISynth.sol": { + "content": "pragma solidity >=0.4.24;\n\n// https://docs.synthetix.io/contracts/source/interfaces/isynth\ninterface ISynth {\n // Views\n function currencyKey() external view returns (bytes32);\n\n function transferableSynths(address account) external view returns (uint);\n\n // Mutative functions\n function transferAndSettle(address to, uint value) external returns (bool);\n\n function transferFromAndSettle(\n address from,\n address to,\n uint value\n ) external returns (bool);\n\n // Restricted: used internally to Synthetix\n function burn(address account, uint amount) external;\n\n function issue(address account, uint amount) external;\n}\n" + }, + "synthetix/contracts/interfaces/ISynthetix.sol": { + "content": "pragma solidity >=0.4.24;\n\nimport \"./ISynth.sol\";\nimport \"./IVirtualSynth.sol\";\n\n// https://docs.synthetix.io/contracts/source/interfaces/isynthetix\ninterface ISynthetix {\n // Views\n function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);\n\n function availableCurrencyKeys() external view returns (bytes32[] memory);\n\n function availableSynthCount() external view returns (uint);\n\n function availableSynths(uint index) external view returns (ISynth);\n\n function collateral(address account) external view returns (uint);\n\n function collateralisationRatio(address issuer) external view returns (uint);\n\n function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint);\n\n function isWaitingPeriod(bytes32 currencyKey) external view returns (bool);\n\n function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);\n\n function remainingIssuableSynths(address issuer)\n external\n view\n returns (\n uint maxIssuable,\n uint alreadyIssued,\n uint totalSystemDebt\n );\n\n function synths(bytes32 currencyKey) external view returns (ISynth);\n\n function synthsByAddress(address synthAddress) external view returns (bytes32);\n\n function totalIssuedSynths(bytes32 currencyKey) external view returns (uint);\n\n function totalIssuedSynthsExcludeOtherCollateral(bytes32 currencyKey) external view returns (uint);\n\n function transferableSynthetix(address account) external view returns (uint transferable);\n\n // Mutative Functions\n function burnSynths(uint amount) external;\n\n function burnSynthsOnBehalf(address burnForAddress, uint amount) external;\n\n function burnSynthsToTarget() external;\n\n function burnSynthsToTargetOnBehalf(address burnForAddress) external;\n\n function exchange(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey\n ) external returns (uint amountReceived);\n\n function exchangeOnBehalf(\n address exchangeForAddress,\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey\n ) external returns (uint amountReceived);\n\n function exchangeWithTracking(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n address rewardAddress,\n bytes32 trackingCode\n ) external returns (uint amountReceived);\n\n function exchangeWithTrackingForInitiator(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n address rewardAddress,\n bytes32 trackingCode\n ) external returns (uint amountReceived);\n\n function exchangeOnBehalfWithTracking(\n address exchangeForAddress,\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n address rewardAddress,\n bytes32 trackingCode\n ) external returns (uint amountReceived);\n\n function exchangeWithVirtual(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n bytes32 trackingCode\n ) external returns (uint amountReceived, IVirtualSynth vSynth);\n\n function exchangeAtomically(\n bytes32 sourceCurrencyKey,\n uint sourceAmount,\n bytes32 destinationCurrencyKey,\n bytes32 trackingCode\n ) external returns (uint amountReceived);\n\n function issueMaxSynths() external;\n\n function issueMaxSynthsOnBehalf(address issueForAddress) external;\n\n function issueSynths(uint amount) external;\n\n function issueSynthsOnBehalf(address issueForAddress, uint amount) external;\n\n function mint() external returns (bool);\n\n function settle(bytes32 currencyKey)\n external\n returns (\n uint reclaimed,\n uint refunded,\n uint numEntries\n );\n\n // Liquidations\n function liquidateDelinquentAccount(address account, uint susdAmount) external returns (bool);\n\n // Restricted Functions\n\n function mintSecondary(address account, uint amount) external;\n\n function mintSecondaryRewards(uint amount) external;\n\n function burnSecondary(address account, uint amount) external;\n}\n" + }, + "synthetix/contracts/interfaces/IVirtualSynth.sol": { + "content": "pragma solidity >=0.4.24;\n\nimport \"./ISynth.sol\";\n\ninterface IVirtualSynth {\n // Views\n function balanceOfUnderlying(address account) external view returns (uint);\n\n function rate() external view returns (uint);\n\n function readyToSettle() external view returns (bool);\n\n function secsLeftInWaitingPeriod() external view returns (uint);\n\n function settled() external view returns (bool);\n\n function synth() external view returns (ISynth);\n\n // Mutative functions\n function settle(address account) external;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 10000 + }, + "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/deployments/base_testnet/solcInputs/faeaaf1f06e012c3200d7f368f424bd7.json b/deployments/base_testnet/solcInputs/faeaaf1f06e012c3200d7f368f424bd7.json new file mode 100644 index 00000000..6fc4cb72 --- /dev/null +++ b/deployments/base_testnet/solcInputs/faeaaf1f06e012c3200d7f368f424bd7.json @@ -0,0 +1,131 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-4.7.3/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-4.7.3/proxy/Clones.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n *\n * This function uses the create opcode, which should never revert.\n */\n function clone(address implementation) internal returns (address instance) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, implementation))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create(0, ptr, 0x37)\n }\n require(instance != address(0), \"ERC1167: create failed\");\n }\n\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n *\n * This function uses the create2 opcode and a `salt` to deterministically deploy\n * the clone. Using the same `implementation` and `salt` multiple time will revert, since\n * the clones cannot be deployed twice at the same address.\n */\n function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, implementation))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)\n instance := create2(0, ptr, 0x37, salt)\n }\n require(instance != address(0), \"ERC1167: create2 failed\");\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(\n address implementation,\n bytes32 salt,\n address deployer\n ) internal pure returns (address predicted) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)\n mstore(add(ptr, 0x14), shl(0x60, implementation))\n mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)\n mstore(add(ptr, 0x38), shl(0x60, deployer))\n mstore(add(ptr, 0x4c), salt)\n mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))\n predicted := keccak256(add(ptr, 0x37), 0x55)\n }\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(address implementation, bytes32 salt)\n internal\n view\n returns (address predicted)\n {\n return predictDeterministicAddress(implementation, salt, address(this));\n }\n}\n" + }, + "@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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" + }, + "@openzeppelin/contracts-4.7.3/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts-4.7.3/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-4.7.3/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-4.7.3/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts-4.7.3/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 /// @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}\n" + }, + "@openzeppelin/contracts-4.7.3/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-upgradeable-4.7.3/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-upgradeable-4.7.3/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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. Equivalent to `reinitializer(1)`.\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 * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\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 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 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" + }, + "@openzeppelin/contracts-upgradeable-4.7.3/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-4.7.3/security/ReentrancyGuardUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\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-4.7.3/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin 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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\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 function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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 /**\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[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.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 \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/ContextUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {\n function __ERC20Burnable_init() internal onlyInitializing {\n }\n\n function __ERC20Burnable_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\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-4.7.3/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-4.7.3/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-4.7.3/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @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}\n" + }, + "@openzeppelin/contracts-upgradeable-4.7.3/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" + }, + "contracts/AmplificationUtilsV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"./SwapUtilsV2.sol\";\n\n/**\n * @title AmplificationUtils library\n * @notice A library to calculate and ramp the A parameter of a given `SwapUtilsV2.Swap` struct.\n * This library assumes the struct is fully validated.\n */\nlibrary AmplificationUtilsV2 {\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n // Constant values used in ramping A calculations\n uint256 public constant A_PRECISION = 100;\n uint256 public constant MAX_A = 10**6;\n uint256 private constant MAX_A_CHANGE = 2;\n uint256 private constant MIN_RAMP_TIME = 14 days;\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter\n */\n function getA(SwapUtilsV2.Swap storage self)\n external\n view\n returns (uint256)\n {\n return (_getAPrecise(self) / A_PRECISION);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function getAPrecise(SwapUtilsV2.Swap storage self)\n external\n view\n returns (uint256)\n {\n return _getAPrecise(self);\n }\n\n /**\n * @notice Return A in its raw precision\n * @dev See the StableSwap paper for details\n * @param self Swap struct to read from\n * @return A parameter in its raw precision form\n */\n function _getAPrecise(SwapUtilsV2.Swap storage self)\n internal\n view\n returns (uint256)\n {\n uint256 t1 = self.futureATime; // time when ramp is finished\n uint256 a1 = self.futureA; // final A value when ramp is finished\n\n if (block.timestamp < t1) {\n uint256 t0 = self.initialATime; // time when ramp is started\n uint256 a0 = self.initialA; // initial A value when ramp is started\n if (a1 > a0) {\n // a0 + (a1 - a0) * (block.timestamp - t0) / (t1 - t0)\n return a0 + (((a1 - a0) * (block.timestamp - t0)) / (t1 - t0));\n } else {\n // a0 - (a0 - a1) * (block.timestamp - t0) / (t1 - t0)\n return a0 - (((a0 - a1) * (block.timestamp - t0)) / (t1 - t0));\n }\n } else {\n return a1;\n }\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA_ and futureTime_\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param self Swap struct to update\n * @param futureA_ the new A to ramp towards\n * @param futureTime_ timestamp when the new A should be reached\n */\n function rampA(\n SwapUtilsV2.Swap storage self,\n uint256 futureA_,\n uint256 futureTime_\n ) external {\n require(\n block.timestamp >= (self.initialATime + (1 days)),\n \"Wait 1 day before starting ramp\"\n );\n require(\n futureTime_ >= (block.timestamp + MIN_RAMP_TIME),\n \"Insufficient ramp time\"\n );\n require(\n futureA_ > 0 && futureA_ < MAX_A,\n \"futureA_ must be > 0 and < MAX_A\"\n );\n\n uint256 initialAPrecise = _getAPrecise(self);\n uint256 futureAPrecise = futureA_ * A_PRECISION;\n\n if (futureAPrecise < initialAPrecise) {\n require(\n (futureAPrecise * MAX_A_CHANGE) >= initialAPrecise,\n \"futureA_ is too small\"\n );\n } else {\n require(\n futureAPrecise <= (initialAPrecise * MAX_A_CHANGE),\n \"futureA_ is too large\"\n );\n }\n\n self.initialA = initialAPrecise;\n self.futureA = futureAPrecise;\n self.initialATime = block.timestamp;\n self.futureATime = futureTime_;\n\n emit RampA(\n initialAPrecise,\n futureAPrecise,\n block.timestamp,\n futureTime_\n );\n }\n\n /**\n * @notice Stops ramping A immediately. Once this function is called, rampA()\n * cannot be called for another 24 hours\n * @param self Swap struct to update\n */\n function stopRampA(SwapUtilsV2.Swap storage self) external {\n require(self.futureATime > block.timestamp, \"Ramp is already stopped\");\n\n uint256 currentA = _getAPrecise(self);\n self.initialA = currentA;\n self.futureA = currentA;\n self.initialATime = block.timestamp;\n self.futureATime = block.timestamp;\n\n emit StopRampA(currentA, block.timestamp);\n }\n}\n" + }, + "contracts/interfaces/IAllowlistV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\ninterface IAllowlistV1 {\n function getPoolAccountLimit(address poolAddress)\n external\n view\n returns (uint256);\n\n function getPoolCap(address poolAddress) external view returns (uint256);\n\n function verifyAddress(address account, bytes32[] calldata merkleProof)\n external\n returns (bool);\n}\n" + }, + "contracts/interfaces/IMetaSwapDepositV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\";\nimport \"./ISwapV2.sol\";\nimport \"./IMetaSwapV1.sol\";\n\ninterface IMetaSwapDepositV1 {\n function initialize(\n ISwapV2 _baseSwap,\n IMetaSwapV1 _metaSwap,\n IERC20 _metaLPToken\n ) external;\n}\n" + }, + "contracts/interfaces/IMetaSwapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\";\nimport \"./ISwapV2.sol\";\n\ninterface IMetaSwapV1 {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function isGuarded() external view returns (bool);\n\n function metaSwapStorage()\n external\n view\n returns (\n address baseSwap,\n uint256 baseVirtualPrice,\n uint256 baseCacheLastUpdated\n );\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateSwapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) external;\n\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwapV2 baseSwap\n ) external;\n\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function swapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n}\n" + }, + "contracts/interfaces/ISwapV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/ERC20.sol\";\nimport \"./IAllowlistV1.sol\";\n\ninterface ISwapV2 {\n // pool data view functions\n function getA() external view returns (uint256);\n\n function getAPrecise() external view returns (uint256);\n\n function getAllowlist() external view returns (IAllowlistV1);\n\n function getToken(uint8 index) external view returns (IERC20);\n\n function getTokenIndex(address tokenAddress) external view returns (uint8);\n\n function getTokenBalance(uint8 index) external view returns (uint256);\n\n function getVirtualPrice() external view returns (uint256);\n\n function owner() external view returns (address);\n\n function isGuarded() external view returns (bool);\n\n function paused() external view returns (bool);\n\n function swapStorage()\n external\n view\n returns (\n uint256,\n uint256,\n uint256,\n uint256,\n uint256,\n uint256,\n address\n );\n\n // min return calculation functions\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256);\n\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256);\n\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory);\n\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 availableTokenAmount);\n\n // state modifying functions\n function initialize(\n IERC20[] memory pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 a,\n uint256 fee,\n uint256 adminFee,\n address lpTokenTargetAddress\n ) external;\n\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external returns (uint256);\n\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external returns (uint256[] memory);\n\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external returns (uint256);\n\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external returns (uint256);\n}\n" + }, + "contracts/LPTokenV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/token/ERC20/extensions/ERC20BurnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\";\nimport \"./interfaces/ISwapV2.sol\";\n\n/**\n * @title Liquidity Provider Token\n * @notice This token is an ERC20 detailed token with added capability to be minted by the owner.\n * It is used to represent user's shares when providing liquidity to swap contracts.\n * @dev Only Swap contracts should initialize and own LPToken contracts.\n */\ncontract LPTokenV2 is ERC20BurnableUpgradeable, OwnableUpgradeable {\n /**\n * @notice Initializes this LPToken contract with the given name and symbol\n * @dev The caller of this function will become the owner. A Swap contract should call this\n * in its initializer function.\n * @param name name of this token\n * @param symbol symbol of this token\n */\n function initialize(string memory name, string memory symbol)\n external\n initializer\n returns (bool)\n {\n __Context_init_unchained();\n __ERC20_init_unchained(name, symbol);\n __Ownable_init_unchained();\n return true;\n }\n\n /**\n * @notice Mints the given amount of LPToken to the recipient.\n * @dev only owner can call this mint function\n * @param recipient address of account to receive the tokens\n * @param amount amount of tokens to mint\n */\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(amount != 0, \"LPToken: cannot mint 0\");\n _mint(recipient, amount);\n }\n\n /**\n * @dev Overrides ERC20._beforeTokenTransfer() which get called on every transfers including\n * minting and burning. This ensures that Swap.updateUserWithdrawFees are called everytime.\n * This assumes the owner is set to a Swap contract's address.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20Upgradeable) {\n super._beforeTokenTransfer(from, to, amount);\n require(to != address(this), \"LPToken: cannot send to itself\");\n }\n}\n" + }, + "contracts/MathUtilsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title MathUtils library\n * @notice A library to be used in conjunction with SafeMath. Contains functions for calculating\n * differences between two uint256.\n */\nlibrary MathUtilsV1 {\n /**\n * @notice Compares a and b and returns true if the difference between a and b\n * is less than 1 or equal to each other.\n * @param a uint256 to compare with\n * @param b uint256 to compare with\n * @return True if the difference between a and b is less than 1 or equal,\n * otherwise return false\n */\n function within1(uint256 a, uint256 b) internal pure returns (bool) {\n return (difference(a, b) <= 1);\n }\n\n /**\n * @notice Calculates absolute difference between a and b\n * @param a uint256 to compare with\n * @param b uint256 to compare with\n * @return Difference between a and b\n */\n function difference(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a > b) {\n return a - b;\n }\n return b - a;\n }\n}\n" + }, + "contracts/meta/MetaSwapDepositV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/security/ReentrancyGuardUpgradeable.sol\";\nimport \"../LPTokenV2.sol\";\nimport \"../interfaces/ISwapV2.sol\";\nimport \"../interfaces/IMetaSwapV1.sol\";\n\n/**\n * @title MetaSwapDeposit\n * @notice This contract flattens the LP token in a MetaSwap pool for easier user access. MetaSwap must be\n * deployed before this contract can be initialized successfully.\n *\n * For example, suppose there exists a base Swap pool consisting of [DAI, USDC, USDT].\n * Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken] to allow trades between either\n * the LP token or the underlying tokens and sUSD.\n *\n * MetaSwapDeposit flattens the LP token and remaps them to a single array, allowing users\n * to ignore the dependency on BaseSwapLPToken. Using the above example, MetaSwapDeposit can act\n * as a Swap containing [sUSD, DAI, USDC, USDT] tokens.\n */\ncontract MetaSwapDepositV1 is Initializable, ReentrancyGuardUpgradeable {\n using SafeERC20 for IERC20;\n\n ISwapV2 public baseSwap;\n IMetaSwapV1 public metaSwap;\n IERC20[] public baseTokens;\n IERC20[] public metaTokens;\n IERC20[] public tokens;\n IERC20 public metaLPToken;\n\n uint256 constant MAX_UINT256 = 2**256 - 1;\n\n struct RemoveLiquidityImbalanceInfo {\n ISwapV2 baseSwap;\n IMetaSwapV1 metaSwap;\n IERC20 metaLPToken;\n uint8 baseLPTokenIndex;\n bool withdrawFromBase;\n uint256 leftoverMetaLPTokenAmount;\n }\n\n /**\n * @notice Sets the address for the base Swap contract, MetaSwap contract, and the\n * MetaSwap LP token contract.\n * @param _baseSwap the address of the base Swap contract\n * @param _metaSwap the address of the MetaSwap contract\n * @param _metaLPToken the address of the MetaSwap LP token contract\n */\n function initialize(\n ISwapV2 _baseSwap,\n IMetaSwapV1 _metaSwap,\n IERC20 _metaLPToken\n ) external initializer {\n __ReentrancyGuard_init();\n // Check and approve base level tokens to be deposited to the base Swap contract\n {\n uint8 i;\n for (; i < 32; i++) {\n try _baseSwap.getToken(i) returns (IERC20 token) {\n baseTokens.push(token);\n token.safeApprove(address(_baseSwap), MAX_UINT256);\n token.safeApprove(address(_metaSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"baseSwap must have at least 2 tokens\");\n }\n\n // Check and approve meta level tokens to be deposited to the MetaSwap contract\n IERC20 baseLPToken;\n {\n uint8 i;\n for (; i < 32; i++) {\n try _metaSwap.getToken(i) returns (IERC20 token) {\n baseLPToken = token;\n metaTokens.push(token);\n tokens.push(token);\n token.safeApprove(address(_metaSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"metaSwap must have at least 2 tokens\");\n }\n\n // Flatten baseTokens and append it to tokens array\n tokens[tokens.length - 1] = baseTokens[0];\n for (uint8 i = 1; i < baseTokens.length; i++) {\n tokens.push(baseTokens[i]);\n }\n\n // Approve base Swap LP token to be burned by the base Swap contract for withdrawing\n baseLPToken.safeApprove(address(_baseSwap), MAX_UINT256);\n // Approve MetaSwap LP token to be burned by the MetaSwap contract for withdrawing\n _metaLPToken.safeApprove(address(_metaSwap), MAX_UINT256);\n\n // Initialize storage variables\n baseSwap = _baseSwap;\n metaSwap = _metaSwap;\n metaLPToken = _metaLPToken;\n }\n\n // Mutative functions\n\n /**\n * @notice Swap two underlying tokens using the meta pool and the base pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n tokens[tokenIndexFrom].safeTransferFrom(msg.sender, address(this), dx);\n uint256 tokenToAmount = metaSwap.swapUnderlying(\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy,\n deadline\n );\n tokens[tokenIndexTo].safeTransfer(msg.sender, tokenToAmount);\n return tokenToAmount;\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n // Read to memory to save on gas\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\n\n require(amounts.length == memBaseTokens.length + baseLPTokenIndex);\n\n uint256 baseLPTokenAmount;\n {\n // Transfer base tokens from the caller and deposit to the base Swap pool\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\n bool shouldDepositBaseTokens;\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\n IERC20 token = memBaseTokens[i];\n uint256 depositAmount = amounts[baseLPTokenIndex + i];\n if (depositAmount > 0) {\n token.safeTransferFrom(\n msg.sender,\n address(this),\n depositAmount\n );\n baseAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\n // if there are any base Swap level tokens, flag it for deposits\n shouldDepositBaseTokens = true;\n }\n }\n if (shouldDepositBaseTokens) {\n // Deposit any base Swap level tokens and receive baseLPToken\n baseLPTokenAmount = baseSwap.addLiquidity(\n baseAmounts,\n 0,\n deadline\n );\n }\n }\n\n uint256 metaLPTokenAmount;\n {\n // Transfer remaining meta level tokens from the caller\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n IERC20 token = memMetaTokens[i];\n uint256 depositAmount = amounts[i];\n if (depositAmount > 0) {\n token.safeTransferFrom(\n msg.sender,\n address(this),\n depositAmount\n );\n metaAmounts[i] = token.balanceOf(address(this)); // account for any fees on transfer\n }\n }\n // Update the baseLPToken amount that will be deposited\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\n\n // Deposit the meta level tokens and the baseLPToken\n metaLPTokenAmount = metaSwap.addLiquidity(\n metaAmounts,\n minToMint,\n deadline\n );\n }\n\n // Transfer the meta lp token to the caller\n metaLPToken.safeTransfer(msg.sender, metaLPTokenAmount);\n\n return metaLPTokenAmount;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n ) external nonReentrant returns (uint256[] memory) {\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256[] memory totalRemovedAmounts;\n\n {\n uint256 numOfAllTokens = memBaseTokens.length +\n memMetaTokens.length -\n 1;\n require(minAmounts.length == numOfAllTokens, \"out of range\");\n totalRemovedAmounts = new uint256[](numOfAllTokens);\n }\n\n // Transfer meta lp token from the caller to this\n metaLPToken.safeTransferFrom(msg.sender, address(this), amount);\n\n uint256 baseLPTokenAmount;\n {\n // Remove liquidity from the MetaSwap pool\n uint256[] memory removedAmounts;\n uint256 baseLPTokenIndex = memMetaTokens.length - 1;\n {\n uint256[] memory metaMinAmounts = new uint256[](\n memMetaTokens.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n metaMinAmounts[i] = minAmounts[i];\n }\n removedAmounts = metaSwap.removeLiquidity(\n amount,\n metaMinAmounts,\n deadline\n );\n }\n\n // Send the meta level tokens to the caller\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n totalRemovedAmounts[i] = removedAmounts[i];\n memMetaTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\n }\n baseLPTokenAmount = removedAmounts[baseLPTokenIndex];\n\n // Remove liquidity from the base Swap pool\n {\n uint256[] memory baseMinAmounts = new uint256[](\n memBaseTokens.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];\n }\n removedAmounts = baseSwap.removeLiquidity(\n baseLPTokenAmount,\n baseMinAmounts,\n deadline\n );\n }\n\n // Send the base level tokens to the caller\n for (uint8 i = 0; i < memBaseTokens.length; i++) {\n totalRemovedAmounts[baseLPTokenIndex + i] = removedAmounts[i];\n memBaseTokens[i].safeTransfer(msg.sender, removedAmounts[i]);\n }\n }\n\n return totalRemovedAmounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\n uint8 baseTokensLength = uint8(baseTokens.length);\n\n // Transfer metaLPToken from the caller\n metaLPToken.safeTransferFrom(msg.sender, address(this), tokenAmount);\n\n IERC20 token;\n if (tokenIndex < baseLPTokenIndex) {\n // When the desired token is meta level token, we can just call `removeLiquidityOneToken` directly\n metaSwap.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount,\n deadline\n );\n token = metaTokens[tokenIndex];\n } else if (tokenIndex < baseLPTokenIndex + baseTokensLength) {\n // When the desired token is a base level token, we need to first withdraw via baseLPToken, then withdraw\n // the desired token from the base Swap contract.\n uint256 removedBaseLPTokenAmount = metaSwap.removeLiquidityOneToken(\n tokenAmount,\n baseLPTokenIndex,\n 0,\n deadline\n );\n\n baseSwap.removeLiquidityOneToken(\n removedBaseLPTokenAmount,\n tokenIndex - baseLPTokenIndex,\n minAmount,\n deadline\n );\n token = baseTokens[tokenIndex - baseLPTokenIndex];\n } else {\n revert(\"out of range\");\n }\n\n uint256 amountWithdrawn = token.balanceOf(address(this));\n token.safeTransfer(msg.sender, amountWithdrawn);\n return amountWithdrawn;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n ) external nonReentrant returns (uint256) {\n IERC20[] memory memBaseTokens = baseTokens;\n IERC20[] memory memMetaTokens = metaTokens;\n uint256[] memory metaAmounts = new uint256[](memMetaTokens.length);\n uint256[] memory baseAmounts = new uint256[](memBaseTokens.length);\n\n require(\n amounts.length == memBaseTokens.length + memMetaTokens.length - 1,\n \"out of range\"\n );\n\n RemoveLiquidityImbalanceInfo memory v = RemoveLiquidityImbalanceInfo(\n baseSwap,\n metaSwap,\n metaLPToken,\n uint8(metaAmounts.length - 1),\n false,\n 0\n );\n\n for (uint8 i = 0; i < v.baseLPTokenIndex; i++) {\n metaAmounts[i] = amounts[i];\n }\n\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n baseAmounts[i] = amounts[v.baseLPTokenIndex + i];\n if (baseAmounts[i] > 0) {\n v.withdrawFromBase = true;\n }\n }\n\n // Calculate how much base LP token we need to get the desired amount of underlying tokens\n if (v.withdrawFromBase) {\n metaAmounts[v.baseLPTokenIndex] =\n (v.baseSwap.calculateTokenAmount(baseAmounts, false) * 10005) /\n 10000;\n }\n\n // Transfer MetaSwap LP token from the caller to this contract\n v.metaLPToken.safeTransferFrom(\n msg.sender,\n address(this),\n maxBurnAmount\n );\n\n // Withdraw the paired meta level tokens and the base LP token from the MetaSwap pool\n uint256 burnedMetaLPTokenAmount = v.metaSwap.removeLiquidityImbalance(\n metaAmounts,\n maxBurnAmount,\n deadline\n );\n v.leftoverMetaLPTokenAmount = maxBurnAmount - burnedMetaLPTokenAmount;\n\n // If underlying tokens are desired, withdraw them from the base Swap pool\n if (v.withdrawFromBase) {\n v.baseSwap.removeLiquidityImbalance(\n baseAmounts,\n metaAmounts[v.baseLPTokenIndex],\n deadline\n );\n\n // Base Swap may require LESS base LP token than the amount we have\n // In that case, deposit it to the MetaSwap pool.\n uint256[] memory leftovers = new uint256[](metaAmounts.length);\n IERC20 baseLPToken = memMetaTokens[v.baseLPTokenIndex];\n uint256 leftoverBaseLPTokenAmount = baseLPToken.balanceOf(\n address(this)\n );\n if (leftoverBaseLPTokenAmount > 0) {\n leftovers[v.baseLPTokenIndex] = leftoverBaseLPTokenAmount;\n v.leftoverMetaLPTokenAmount =\n v.leftoverMetaLPTokenAmount +\n v.metaSwap.addLiquidity(leftovers, 0, deadline);\n }\n }\n\n // Transfer all withdrawn tokens to the caller\n for (uint8 i = 0; i < amounts.length; i++) {\n IERC20 token;\n if (i < v.baseLPTokenIndex) {\n token = memMetaTokens[i];\n } else {\n token = memBaseTokens[i - v.baseLPTokenIndex];\n }\n if (amounts[i] > 0) {\n token.safeTransfer(msg.sender, amounts[i]);\n }\n }\n\n // If there were any extra meta lp token, transfer them back to the caller as well\n if (v.leftoverMetaLPTokenAmount > 0) {\n v.metaLPToken.safeTransfer(msg.sender, v.leftoverMetaLPTokenAmount);\n }\n\n return maxBurnAmount - v.leftoverMetaLPTokenAmount;\n }\n\n // VIEW FUNCTIONS\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running. When withdrawing from the base pool in imbalanced\n * fashion, the recommended slippage setting is 0.2% or higher.\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n returns (uint256)\n {\n uint256[] memory metaAmounts = new uint256[](metaTokens.length);\n uint256[] memory baseAmounts = new uint256[](baseTokens.length);\n uint256 baseLPTokenIndex = metaAmounts.length - 1;\n\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n metaAmounts[i] = amounts[i];\n }\n\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n baseAmounts[i] = amounts[baseLPTokenIndex + i];\n }\n\n uint256 baseLPTokenAmount = baseSwap.calculateTokenAmount(\n baseAmounts,\n deposit\n );\n metaAmounts[baseLPTokenIndex] = baseLPTokenAmount;\n\n return metaSwap.calculateTokenAmount(metaAmounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n returns (uint256[] memory)\n {\n uint256[] memory metaAmounts = metaSwap.calculateRemoveLiquidity(\n amount\n );\n uint8 baseLPTokenIndex = uint8(metaAmounts.length - 1);\n uint256[] memory baseAmounts = baseSwap.calculateRemoveLiquidity(\n metaAmounts[baseLPTokenIndex]\n );\n\n uint256[] memory totalAmounts = new uint256[](\n baseLPTokenIndex + baseAmounts.length\n );\n for (uint8 i = 0; i < baseLPTokenIndex; i++) {\n totalAmounts[i] = metaAmounts[i];\n }\n for (uint8 i = 0; i < baseAmounts.length; i++) {\n totalAmounts[baseLPTokenIndex + i] = baseAmounts[i];\n }\n\n return totalAmounts;\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256) {\n uint8 baseLPTokenIndex = uint8(metaTokens.length - 1);\n\n if (tokenIndex < baseLPTokenIndex) {\n return\n metaSwap.calculateRemoveLiquidityOneToken(\n tokenAmount,\n tokenIndex\n );\n } else {\n uint256 baseLPTokenAmount = metaSwap\n .calculateRemoveLiquidityOneToken(\n tokenAmount,\n baseLPTokenIndex\n );\n return\n baseSwap.calculateRemoveLiquidityOneToken(\n baseLPTokenAmount,\n tokenIndex - baseLPTokenIndex\n );\n }\n }\n\n /**\n * @notice Returns the address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * This is a flattened representation of the pooled tokens.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) external view returns (IERC20) {\n require(index < tokens.length, \"index out of range\");\n return tokens[index];\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256) {\n return\n metaSwap.calculateSwapUnderlying(tokenIndexFrom, tokenIndexTo, dx);\n }\n}\n" + }, + "contracts/meta/MetaSwapUtilsV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"../LPTokenV2.sol\";\nimport \"../interfaces/ISwapV2.sol\";\nimport \"../MathUtilsV1.sol\";\nimport \"../SwapUtilsV2.sol\";\n\n/**\n * @title MetaSwapUtils library\n * @notice A library to be used within MetaSwap.sol. Contains functions responsible for custody and AMM functionalities.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT]. Then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n *\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary MetaSwapUtilsV1 {\n using SafeERC20 for IERC20;\n using MathUtilsV1 for uint256;\n using AmplificationUtilsV2 for SwapUtilsV2.Swap;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event TokenSwapUnderlying(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n\n struct MetaSwap {\n // Meta-Swap related parameters\n ISwapV2 baseSwap;\n uint256 baseVirtualPrice;\n uint256 baseCacheLastUpdated;\n IERC20[] baseTokens;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n uint256 xpi;\n }\n\n // Struct storing variables used in calculation in removeLiquidityImbalance function\n // to avoid stack too deep error\n struct ManageLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n LPTokenV2 lpToken;\n uint256 totalSupply;\n uint256 preciseA;\n uint256 baseVirtualPrice;\n uint256[] tokenPrecisionMultipliers;\n uint256[] newBalances;\n }\n\n struct SwapUnderlyingInfo {\n uint256 x;\n uint256 dx;\n uint256 dy;\n uint256[] tokenPrecisionMultipliers;\n uint256[] oldBalances;\n IERC20[] baseTokens;\n IERC20 tokenFrom;\n uint8 metaIndexFrom;\n IERC20 tokenTo;\n uint8 metaIndexTo;\n uint256 baseVirtualPrice;\n }\n\n struct CalculateSwapUnderlyingInfo {\n uint256 baseVirtualPrice;\n ISwapV2 baseSwap;\n uint8 baseLPTokenIndex;\n uint8 baseTokensLength;\n uint8 metaIndexTo;\n uint256 x;\n uint256 dy;\n }\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount.mul(fee).div(FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Cache expire time for the stored value of base Swap's virtual price\n uint256 public constant BASE_CACHE_EXPIRE_TIME = 10 minutes;\n uint256 public constant BASE_VIRTUAL_PRICE_PRECISION = 10**18;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n /**\n * @notice Return the stored value of base Swap's virtual price. If\n * value was updated past BASE_CACHE_EXPIRE_TIME, then read it directly\n * from the base Swap contract.\n * @param metaSwapStorage MetaSwap struct to read from\n * @return base Swap's virtual price\n */\n function _getBaseVirtualPrice(MetaSwap storage metaSwapStorage)\n internal\n view\n returns (uint256)\n {\n if (\n block.timestamp >\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\n ) {\n return metaSwapStorage.baseSwap.getVirtualPrice();\n }\n return metaSwapStorage.baseVirtualPrice;\n }\n\n function _getBaseSwapFee(ISwapV2 baseSwap)\n internal\n view\n returns (uint256 swapFee)\n {\n (, , , , swapFee, , ) = baseSwap.swapStorage();\n }\n\n /**\n * @notice Calculate how much the user would receive when withdrawing via single token\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @return dy the amount of token user will receive\n */\n function calculateWithdrawOneToken(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n _getBaseVirtualPrice(metaSwapStorage),\n self.lpToken.totalSupply()\n );\n }\n\n function _calculateWithdrawOneToken(\n SwapUtilsV2.Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 baseVirtualPrice,\n uint256 totalSupply\n ) internal view returns (uint256, uint256) {\n uint256 dy;\n uint256 dySwapFee;\n\n {\n uint256 currentY;\n uint256 newY;\n\n // Calculate how much to withdraw\n (dy, newY, currentY) = _calculateWithdrawOneTokenDY(\n self,\n tokenIndex,\n tokenAmount,\n baseVirtualPrice,\n totalSupply\n );\n\n // Calculate the associated swap fee\n dySwapFee =\n ((currentY - newY) /\n self.tokenPrecisionMultipliers[tokenIndex]) -\n dy;\n }\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @param baseVirtualPrice the virtual price of the base swap's LP token\n * @return the dy excluding swap fee, the new y after withdrawing one token, and current y\n */\n function _calculateWithdrawOneTokenDY(\n SwapUtilsV2.Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount,\n uint256 baseVirtualPrice,\n uint256 totalSupply\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self, baseVirtualPrice);\n require(tokenIndex < xp.length, \"Token index out of range\");\n\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(\n 0,\n 0,\n 0,\n 0,\n self._getAPrecise(),\n 0\n );\n v.d0 = SwapUtilsV2.getD(xp, v.preciseA);\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = SwapUtilsV2.getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = SwapUtilsV2._feePerToken(self.swapFee, xp.length);\n for (uint256 i = 0; i < xp.length; i++) {\n v.xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] =\n v.xpi -\n (((\n (i == tokenIndex)\n ? (v.xpi * v.d1) / v.d0 - v.newY\n : v.xpi - ((v.xpi * v.d1) / v.d0)\n ) * v.feePerToken) / FEE_DENOMINATOR);\n }\n\n uint256 dy = xpReduced[tokenIndex] -\n SwapUtilsV2.getYD(v.preciseA, tokenIndex, xpReduced, v.d1);\n\n if (tokenIndex == xp.length - 1) {\n dy = (dy * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\n v.newY = (v.newY * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\n xp[tokenIndex] =\n (xp[tokenIndex] * BASE_VIRTUAL_PRICE_PRECISION) /\n baseVirtualPrice;\n }\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\n\n return (dy, v.newY, xp[tokenIndex]);\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances. The last element will also get scaled up by\n * the given baseVirtualPrice.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @param baseVirtualPrice the base virtual price to scale the balance of the\n * base Swap's LP token.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers,\n uint256 baseVirtualPrice\n ) internal pure returns (uint256[] memory) {\n uint256[] memory xp = SwapUtilsV2._xp(balances, precisionMultipliers);\n uint256 baseLPTokenIndex = balances.length - 1;\n xp[baseLPTokenIndex] =\n (xp[baseLPTokenIndex] * baseVirtualPrice) /\n BASE_VIRTUAL_PRICE_PRECISION;\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(SwapUtilsV2.Swap storage self, uint256 baseVirtualPrice)\n internal\n view\n returns (uint256[] memory)\n {\n return\n _xp(\n self.balances,\n self.tokenPrecisionMultipliers,\n baseVirtualPrice\n );\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @return the virtual price, scaled to precision of BASE_VIRTUAL_PRICE_PRECISION\n */\n function getVirtualPrice(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage\n ) external view returns (uint256) {\n uint256 d = SwapUtilsV2.getD(\n _xp(\n self.balances,\n self.tokenPrecisionMultipliers,\n _getBaseVirtualPrice(metaSwapStorage)\n ),\n self._getAPrecise()\n );\n uint256 supply = self.lpToken.totalSupply();\n if (supply != 0) {\n return (d * BASE_VIRTUAL_PRICE_PRECISION) / supply;\n }\n return 0;\n }\n\n /**\n * @notice Externally calculates a swap between two tokens. The SwapUtils.Swap storage and\n * MetaSwap storage should be from the same MetaSwap contract.\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct from the same contract\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n _getBaseVirtualPrice(metaSwapStorage)\n );\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param baseVirtualPrice the virtual price of the base LP token\n * @return dy the number of tokens the user will get and dyFee the associated fee\n */\n function _calculateSwap(\n SwapUtilsV2.Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 baseVirtualPrice\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory xp = _xp(self, baseVirtualPrice);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 baseLPTokenIndex = xp.length - 1;\n\n uint256 x = dx * self.tokenPrecisionMultipliers[tokenIndexFrom];\n if (tokenIndexFrom == baseLPTokenIndex) {\n // When swapping from a base Swap token, scale up dx by its virtual price\n x = (x * baseVirtualPrice) / BASE_VIRTUAL_PRICE_PRECISION;\n }\n x = x + xp[tokenIndexFrom];\n\n uint256 y = SwapUtilsV2.getY(\n self._getAPrecise(),\n tokenIndexFrom,\n tokenIndexTo,\n x,\n xp\n );\n dy = xp[tokenIndexTo] - y - 1;\n\n if (tokenIndexTo == baseLPTokenIndex) {\n // When swapping to a base Swap token, scale down dy by its virtual price\n dy = (dy * BASE_VIRTUAL_PRICE_PRECISION) / baseVirtualPrice;\n }\n\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\n dy = dy - dyFee;\n\n dy = dy / self.tokenPrecisionMultipliers[tokenIndexTo];\n }\n\n /**\n * @notice Calculates the expected return amount from swapping between\n * the pooled tokens and the underlying tokens of the base Swap pool.\n *\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct from the same contract\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwapUnderlying(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256) {\n CalculateSwapUnderlyingInfo memory v = CalculateSwapUnderlyingInfo(\n _getBaseVirtualPrice(metaSwapStorage),\n metaSwapStorage.baseSwap,\n 0,\n uint8(metaSwapStorage.baseTokens.length),\n 0,\n 0,\n 0\n );\n\n uint256[] memory xp = _xp(self, v.baseVirtualPrice);\n v.baseLPTokenIndex = uint8(xp.length - 1);\n {\n uint8 maxRange = v.baseLPTokenIndex + v.baseTokensLength;\n require(\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\n \"Token index out of range\"\n );\n }\n\n if (tokenIndexFrom < v.baseLPTokenIndex) {\n // tokenFrom is from this pool\n v.x =\n xp[tokenIndexFrom] +\n (dx * self.tokenPrecisionMultipliers[tokenIndexFrom]);\n } else {\n // tokenFrom is from the base pool\n tokenIndexFrom = tokenIndexFrom - v.baseLPTokenIndex;\n if (tokenIndexTo < v.baseLPTokenIndex) {\n uint256[] memory baseInputs = new uint256[](v.baseTokensLength);\n baseInputs[tokenIndexFrom] = dx;\n v.x =\n (v.baseSwap.calculateTokenAmount(baseInputs, true) *\n v.baseVirtualPrice) /\n BASE_VIRTUAL_PRICE_PRECISION;\n // when adding to the base pool,you pay approx 50% of the swap fee\n v.x =\n v.x -\n ((v.x * _getBaseSwapFee(metaSwapStorage.baseSwap)) /\n (FEE_DENOMINATOR * 2)) +\n xp[v.baseLPTokenIndex];\n } else {\n // both from and to are from the base pool\n return\n v.baseSwap.calculateSwap(\n tokenIndexFrom,\n tokenIndexTo - v.baseLPTokenIndex,\n dx\n );\n }\n tokenIndexFrom = v.baseLPTokenIndex;\n }\n\n v.metaIndexTo = v.baseLPTokenIndex;\n if (tokenIndexTo < v.baseLPTokenIndex) {\n v.metaIndexTo = tokenIndexTo;\n }\n\n {\n uint256 y = SwapUtilsV2.getY(\n self._getAPrecise(),\n tokenIndexFrom,\n v.metaIndexTo,\n v.x,\n xp\n );\n v.dy = xp[v.metaIndexTo] - y - 1;\n uint256 dyFee = (v.dy * self.swapFee) / FEE_DENOMINATOR;\n v.dy = v.dy - dyFee;\n }\n\n if (tokenIndexTo < v.baseLPTokenIndex) {\n // tokenTo is from this pool\n v.dy = v.dy / self.tokenPrecisionMultipliers[v.metaIndexTo];\n } else {\n // tokenTo is from the base pool\n v.dy = v.baseSwap.calculateRemoveLiquidityOneToken(\n (v.dy * BASE_VIRTUAL_PRICE_PRECISION) / v.baseVirtualPrice,\n tokenIndexTo - v.baseLPTokenIndex\n );\n }\n\n return v.dy;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param metaSwapStorage MetaSwap struct to read from\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 a = self._getAPrecise();\n uint256 d0;\n uint256 d1;\n {\n uint256 baseVirtualPrice = _getBaseVirtualPrice(metaSwapStorage);\n uint256[] memory balances1 = self.balances;\n uint256[] memory tokenPrecisionMultipliers = self\n .tokenPrecisionMultipliers;\n uint256 numTokens = balances1.length;\n d0 = SwapUtilsV2.getD(\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\n a\n );\n for (uint256 i = 0; i < numTokens; i++) {\n if (deposit) {\n balances1[i] = balances1[i] + amounts[i];\n } else {\n if (amounts[i] > balances1[i]) {\n revert(\"Cannot withdraw more than available\");\n } else {\n unchecked {\n balances1[i] = balances1[i] - amounts[i];\n }\n }\n }\n }\n d1 = SwapUtilsV2.getD(\n _xp(balances1, tokenPrecisionMultipliers, baseVirtualPrice),\n a\n );\n }\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return ((d1 - d0) * totalSupply) / d0;\n } else {\n return ((d0 - d1) * totalSupply) / d0;\n }\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n {\n uint256 pooledTokensLength = self.pooledTokens.length;\n require(\n tokenIndexFrom < pooledTokensLength &&\n tokenIndexTo < pooledTokensLength,\n \"Token index is out of range\"\n );\n }\n\n uint256 transferredDx;\n {\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\n require(\n dx <= tokenFrom.balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n\n {\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n\n // Use the actual transferred amount for AMM math\n transferredDx =\n tokenFrom.balanceOf(address(this)) -\n beforeBalance;\n }\n }\n\n (uint256 dy, uint256 dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n transferredDx,\n _updateBaseVirtualPrice(metaSwapStorage)\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = (dyFee * self.adminFee) /\n FEE_DENOMINATOR /\n self.tokenPrecisionMultipliers[tokenIndexTo];\n\n self.balances[tokenIndexFrom] =\n self.balances[tokenIndexFrom] +\n transferredDx;\n self.balances[tokenIndexTo] =\n self.balances[tokenIndexTo] -\n dy -\n dyAdminFee;\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(\n msg.sender,\n transferredDx,\n dy,\n tokenIndexFrom,\n tokenIndexTo\n );\n\n return dy;\n }\n\n /**\n * @notice Swaps with the underlying tokens of the base Swap pool. For this function,\n * the token indices are flattened out so that underlying tokens are represented\n * in the indices.\n * @dev Since this calls multiple external functions during the execution,\n * it is recommended to protect any function that depends on this with reentrancy guards.\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swapUnderlying(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n SwapUnderlyingInfo memory v = SwapUnderlyingInfo(\n 0,\n 0,\n 0,\n self.tokenPrecisionMultipliers,\n self.balances,\n metaSwapStorage.baseTokens,\n IERC20(address(0)),\n 0,\n IERC20(address(0)),\n 0,\n _updateBaseVirtualPrice(metaSwapStorage)\n );\n\n uint8 baseLPTokenIndex = uint8(v.oldBalances.length - 1);\n\n {\n uint8 maxRange = uint8(baseLPTokenIndex + v.baseTokens.length);\n require(\n tokenIndexFrom < maxRange && tokenIndexTo < maxRange,\n \"Token index out of range\"\n );\n }\n\n ISwapV2 baseSwap = metaSwapStorage.baseSwap;\n\n // Find the address of the token swapping from and the index in MetaSwap's token list\n if (tokenIndexFrom < baseLPTokenIndex) {\n v.tokenFrom = self.pooledTokens[tokenIndexFrom];\n v.metaIndexFrom = tokenIndexFrom;\n } else {\n v.tokenFrom = v.baseTokens[tokenIndexFrom - baseLPTokenIndex];\n v.metaIndexFrom = baseLPTokenIndex;\n }\n\n // Find the address of the token swapping to and the index in MetaSwap's token list\n if (tokenIndexTo < baseLPTokenIndex) {\n v.tokenTo = self.pooledTokens[tokenIndexTo];\n v.metaIndexTo = tokenIndexTo;\n } else {\n v.tokenTo = v.baseTokens[tokenIndexTo - baseLPTokenIndex];\n v.metaIndexTo = baseLPTokenIndex;\n }\n\n // Check for possible fee on transfer\n v.dx = v.tokenFrom.balanceOf(address(this));\n v.tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n v.dx = v.tokenFrom.balanceOf(address(this)) - v.dx; // update dx in case of fee on transfer\n\n if (\n tokenIndexFrom < baseLPTokenIndex || tokenIndexTo < baseLPTokenIndex\n ) {\n // Either one of the tokens belongs to the MetaSwap tokens list\n uint256[] memory xp = _xp(\n v.oldBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n );\n\n if (tokenIndexFrom < baseLPTokenIndex) {\n // Swapping from a MetaSwap token\n v.x =\n xp[tokenIndexFrom] +\n (dx * v.tokenPrecisionMultipliers[tokenIndexFrom]);\n } else {\n // Swapping from one of the tokens hosted in the base Swap\n // This case requires adding the underlying token to the base Swap, then\n // using the base LP token to swap to the desired token\n uint256[] memory baseAmounts = new uint256[](\n v.baseTokens.length\n );\n baseAmounts[tokenIndexFrom - baseLPTokenIndex] = v.dx;\n\n // Add liquidity to the base Swap contract and receive base LP token\n v.dx = baseSwap.addLiquidity(baseAmounts, 0, block.timestamp);\n\n // Calculate the value of total amount of baseLPToken we end up with\n v.x =\n ((v.dx * v.baseVirtualPrice) /\n BASE_VIRTUAL_PRICE_PRECISION) +\n xp[baseLPTokenIndex];\n }\n\n // Calculate how much to withdraw in MetaSwap level and the the associated swap fee\n uint256 dyFee;\n {\n uint256 y = SwapUtilsV2.getY(\n self._getAPrecise(),\n v.metaIndexFrom,\n v.metaIndexTo,\n v.x,\n xp\n );\n v.dy = xp[v.metaIndexTo] - y - 1;\n if (tokenIndexTo >= baseLPTokenIndex) {\n // When swapping to a base Swap token, scale down dy by its virtual price\n v.dy =\n (v.dy * BASE_VIRTUAL_PRICE_PRECISION) /\n v.baseVirtualPrice;\n }\n dyFee = (v.dy * self.swapFee) / FEE_DENOMINATOR;\n v.dy =\n (v.dy - dyFee) /\n v.tokenPrecisionMultipliers[v.metaIndexTo];\n }\n\n // Update the balances array according to the calculated input and output amount\n {\n uint256 dyAdminFee = (dyFee * self.adminFee) / FEE_DENOMINATOR;\n dyAdminFee =\n dyAdminFee /\n v.tokenPrecisionMultipliers[v.metaIndexTo];\n self.balances[v.metaIndexFrom] =\n v.oldBalances[v.metaIndexFrom] +\n v.dx;\n self.balances[v.metaIndexTo] =\n v.oldBalances[v.metaIndexTo] -\n v.dy -\n dyAdminFee;\n }\n\n if (tokenIndexTo >= baseLPTokenIndex) {\n // When swapping to a token that belongs to the base Swap, burn the LP token\n // and withdraw the desired token from the base pool\n uint256 oldBalance = v.tokenTo.balanceOf(address(this));\n baseSwap.removeLiquidityOneToken(\n v.dy,\n tokenIndexTo - baseLPTokenIndex,\n 0,\n block.timestamp\n );\n v.dy = v.tokenTo.balanceOf(address(this)) - oldBalance;\n }\n\n // Check the amount of token to send meets minDy\n require(v.dy >= minDy, \"Swap didn't result in min tokens\");\n } else {\n // Both tokens are from the base Swap pool\n // Do a swap through the base Swap\n v.dy = v.tokenTo.balanceOf(address(this));\n baseSwap.swap(\n tokenIndexFrom - baseLPTokenIndex,\n tokenIndexTo - baseLPTokenIndex,\n v.dx,\n minDy,\n block.timestamp\n );\n v.dy = v.tokenTo.balanceOf(address(this)) - v.dy;\n }\n\n // Send the desired token to the caller\n v.tokenTo.safeTransfer(msg.sender, v.dy);\n\n emit TokenSwapUnderlying(\n msg.sender,\n dx,\n v.dy,\n tokenIndexFrom,\n tokenIndexTo\n );\n\n return v.dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] memory amounts,\n uint256 minToMint\n ) external returns (uint256) {\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(\n amounts.length == pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n uint256[] memory fees = new uint256[](pooledTokens.length);\n\n // current state\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n self.lpToken,\n 0,\n self._getAPrecise(),\n _updateBaseVirtualPrice(metaSwapStorage),\n self.tokenPrecisionMultipliers,\n self.balances\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n if (v.totalSupply != 0) {\n v.d0 = SwapUtilsV2.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n }\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n require(\n v.totalSupply != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = pooledTokens[i].balanceOf(\n address(this)\n );\n pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] =\n pooledTokens[i].balanceOf(address(this)) -\n beforeBalance;\n }\n\n v.newBalances[i] = v.newBalances[i] + amounts[i];\n }\n\n // invariant after change\n v.d1 = SwapUtilsV2.getD(\n _xp(v.newBalances, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n require(v.d1 > v.d0, \"D should increase\");\n\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n uint256 toMint;\n\n if (v.totalSupply != 0) {\n uint256 feePerToken = SwapUtilsV2._feePerToken(\n self.swapFee,\n pooledTokens.length\n );\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = (v.d1 * self.balances[i]) / v.d0;\n fees[i] =\n (feePerToken *\n (idealBalance.difference(v.newBalances[i]))) /\n FEE_DENOMINATOR;\n self.balances[i] =\n v.newBalances[i] -\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\n v.newBalances[i] = v.newBalances[i] - fees[i];\n }\n v.d2 = SwapUtilsV2.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\n } else {\n // the initial depositor doesn't pay fees\n self.balances = v.newBalances;\n toMint = v.d1;\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n self.lpToken.mint(msg.sender, toMint);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply + toMint\n );\n\n return toMint;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n LPTokenV2 lpToken = self.lpToken;\n uint256 totalSupply = lpToken.totalSupply();\n uint256 numTokens = self.pooledTokens.length;\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 dyFee;\n uint256 dy;\n\n (dy, dyFee) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n _updateBaseVirtualPrice(metaSwapStorage),\n totalSupply\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n // Update balances array\n self.balances[tokenIndex] =\n self.balances[tokenIndex] -\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\n\n // Burn the associated LP token from the caller and send the desired token\n lpToken.burnFrom(msg.sender, tokenAmount);\n self.pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n SwapUtilsV2.Swap storage self,\n MetaSwap storage metaSwapStorage,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n // Using this struct to avoid stack too deep error\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n self.lpToken,\n 0,\n self._getAPrecise(),\n _updateBaseVirtualPrice(metaSwapStorage),\n self.tokenPrecisionMultipliers,\n self.balances\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n require(\n amounts.length == v.newBalances.length,\n \"Amounts should match pool tokens\"\n );\n require(maxBurnAmount != 0, \"Must burn more than 0\");\n\n uint256 feePerToken = SwapUtilsV2._feePerToken(\n self.swapFee,\n v.newBalances.length\n );\n\n // Calculate how much LPToken should be burned\n uint256[] memory fees = new uint256[](v.newBalances.length);\n {\n uint256[] memory balances1 = new uint256[](v.newBalances.length);\n\n v.d0 = SwapUtilsV2.getD(\n _xp(\n v.newBalances,\n v.tokenPrecisionMultipliers,\n v.baseVirtualPrice\n ),\n v.preciseA\n );\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n if (amounts[i] > v.newBalances[i]) {\n revert(\"Cannot withdraw more than available\");\n } else {\n unchecked {\n balances1[i] = v.newBalances[i] - amounts[i];\n }\n }\n }\n v.d1 = SwapUtilsV2.getD(\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n uint256 idealBalance = (v.d1 * v.newBalances[i]) / v.d0;\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\n self.balances[i] =\n balances1[i] -\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\n balances1[i] = balances1[i] - fees[i];\n }\n\n v.d2 = SwapUtilsV2.getD(\n _xp(balances1, v.tokenPrecisionMultipliers, v.baseVirtualPrice),\n v.preciseA\n );\n }\n\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n\n // Scale up by withdraw fee\n tokenAmount = tokenAmount + 1;\n\n // Check for max burn amount\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n // Burn the calculated amount of LPToken from the caller and send the desired tokens\n v.lpToken.burnFrom(msg.sender, tokenAmount);\n for (uint256 i = 0; i < v.newBalances.length; i++) {\n self.pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply - tokenAmount\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice Determines if the stored value of base Swap's virtual price is expired.\n * If the last update was past the BASE_CACHE_EXPIRE_TIME, then update the stored value.\n *\n * @param metaSwapStorage MetaSwap struct to read from and write to\n * @return base Swap's virtual price\n */\n function _updateBaseVirtualPrice(MetaSwap storage metaSwapStorage)\n internal\n returns (uint256)\n {\n if (\n block.timestamp >\n metaSwapStorage.baseCacheLastUpdated + BASE_CACHE_EXPIRE_TIME\n ) {\n // When the cache is expired, update it\n uint256 baseVirtualPrice = ISwapV2(metaSwapStorage.baseSwap)\n .getVirtualPrice();\n metaSwapStorage.baseVirtualPrice = baseVirtualPrice;\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\n return baseVirtualPrice;\n } else {\n return metaSwapStorage.baseVirtualPrice;\n }\n }\n}\n" + }, + "contracts/meta/MetaSwapV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nimport \"../SwapV2.sol\";\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"./MetaSwapUtilsV1.sol\";\n\n/**\n * @title MetaSwap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * MetaSwap is a modified version of Swap that allows Swap's LP token to be utilized in pooling with other tokens.\n * As an example, if there is a Swap pool consisting of [DAI, USDC, USDT], then a MetaSwap pool can be created\n * with [sUSD, BaseSwapLPToken] to allow trades between either the LP token or the underlying tokens and sUSD.\n * Note that when interacting with MetaSwap, users cannot deposit or withdraw via underlying tokens. In that case,\n * `MetaSwapDeposit.sol` can be additionally deployed to allow interacting with unwrapped representations of the tokens.\n *\n * @dev Most of the logic is stored as a library `MetaSwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract MetaSwapV1 is SwapV2 {\n using MetaSwapUtilsV1 for SwapUtilsV2.Swap;\n using SafeERC20 for IERC20; //TODO: is this needed? wont compile without it\n\n MetaSwapUtilsV1.MetaSwap public metaSwapStorage;\n\n uint256 constant MAX_UINT256 = 2**256 - 1;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwapUnderlying(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice()\n external\n view\n virtual\n override\n returns (uint256)\n {\n return MetaSwapUtilsV1.getVirtualPrice(swapStorage, metaSwapStorage);\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual override returns (uint256) {\n return\n MetaSwapUtilsV1.calculateSwap(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx\n );\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap. For this function,\n * the token indices are flattened out so that underlying tokens are represented.\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual returns (uint256) {\n return\n MetaSwapUtilsV1.calculateSwapUnderlying(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx\n );\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n virtual\n override\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.calculateTokenAmount(\n swapStorage,\n metaSwapStorage,\n amounts,\n deposit\n );\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view virtual override returns (uint256) {\n return\n MetaSwapUtilsV1.calculateWithdrawOneToken(\n swapStorage,\n metaSwapStorage,\n tokenAmount,\n tokenIndex\n );\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice This overrides Swap's initialize function to prevent initializing\n * without the address of the base Swap contract.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual override initializer {\n revert(\"use initializeMetaSwap() instead\");\n }\n\n /**\n * @notice Initializes this MetaSwap contract with the given parameters.\n * MetaSwap uses an existing Swap pool to expand the available liquidity.\n * _pooledTokens array should contain the base Swap pool's LP token as\n * the last element. For example, if there is a Swap pool consisting of\n * [DAI, USDC, USDT]. Then a MetaSwap pool can be created with [sUSD, BaseSwapLPToken]\n * as _pooledTokens.\n *\n * This will also deploy the LPToken that represents users'\n * LP position. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint new tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept. The last\n * element must be an existing Swap pool's LP token's address.\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n */\n function initializeMetaSwap(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwapV2 baseSwap\n ) public payable virtual initializer {\n __SwapV2_init(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n\n // MetaSwap initializer\n metaSwapStorage.baseSwap = baseSwap;\n metaSwapStorage.baseVirtualPrice = baseSwap.getVirtualPrice();\n metaSwapStorage.baseCacheLastUpdated = block.timestamp;\n\n // Read all tokens that belong to baseSwap\n {\n uint8 i;\n for (; i < 32; i++) {\n try baseSwap.getToken(i) returns (IERC20 token) {\n metaSwapStorage.baseTokens.push(token);\n token.safeApprove(address(baseSwap), MAX_UINT256);\n } catch {\n break;\n }\n }\n require(i > 1, \"baseSwap must pool at least 2 tokens\");\n }\n\n // Check the last element of _pooledTokens is owned by baseSwap\n IERC20 baseLPToken = _pooledTokens[_pooledTokens.length - 1];\n require(\n LPTokenV2(address(baseLPToken)).owner() == address(baseSwap),\n \"baseLPToken is not owned by baseSwap\"\n );\n\n // Pre-approve the baseLPToken to be used by baseSwap\n baseLPToken.safeApprove(address(baseSwap), MAX_UINT256);\n }\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.swap(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy\n );\n }\n\n /**\n * @notice Swap two tokens using this pool and the base pool.\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swapUnderlying(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.swapUnderlying(\n swapStorage,\n metaSwapStorage,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n minDy\n );\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.addLiquidity(\n swapStorage,\n metaSwapStorage,\n amounts,\n minToMint\n );\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.removeLiquidityOneToken(\n swapStorage,\n metaSwapStorage,\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n override\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n MetaSwapUtilsV1.removeLiquidityImbalance(\n swapStorage,\n metaSwapStorage,\n amounts,\n maxBurnAmount\n );\n }\n}\n" + }, + "contracts/OwnerPausableUpgradeableV1.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/security/PausableUpgradeable.sol\";\n\n/**\n * @title OwnerPausable\n * @notice An ownable contract allows the owner to pause and unpause the\n * contract without a delay.\n * @dev Only methods using the provided modifiers will be paused.\n */\nabstract contract OwnerPausableUpgradeableV1 is\n OwnableUpgradeable,\n PausableUpgradeable\n{\n function __OwnerPausable_init() internal onlyInitializing {\n __Context_init_unchained();\n __Ownable_init_unchained();\n __Pausable_init_unchained();\n }\n\n /**\n * @notice Pause the contract. Revert if already paused.\n */\n function pause() external onlyOwner {\n PausableUpgradeable._pause();\n }\n\n /**\n * @notice Unpause the contract. Revert if already unpaused.\n */\n function unpause() external onlyOwner {\n PausableUpgradeable._unpause();\n }\n}\n" + }, + "contracts/SwapDeployerV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-4.7.3/access/Ownable.sol\";\nimport \"@openzeppelin/contracts-4.7.3/proxy/Clones.sol\";\nimport \"./interfaces/ISwapV2.sol\";\nimport \"./interfaces/IMetaSwapV1.sol\";\n\ncontract SwapDeployerV2 is Ownable {\n event NewSwapPool(\n address indexed deployer,\n address swapAddress,\n IERC20[] pooledTokens\n );\n event NewClone(address indexed target, address cloneAddress);\n\n constructor() public Ownable() {}\n\n function clone(address target) external returns (address) {\n address newClone = _clone(target);\n emit NewClone(target, newClone);\n\n return newClone;\n }\n\n function _clone(address target) internal returns (address) {\n return Clones.clone(target);\n }\n\n function deploy(\n address swapAddress,\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) external returns (address) {\n address swapClone = _clone(swapAddress);\n ISwapV2(swapClone).initialize(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n Ownable(swapClone).transferOwnership(owner());\n emit NewSwapPool(msg.sender, swapClone, _pooledTokens);\n return swapClone;\n }\n\n function deployMetaSwap(\n address metaSwapAddress,\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress,\n ISwapV2 baseSwap\n ) external returns (address) {\n address metaSwapClone = _clone(metaSwapAddress);\n IMetaSwapV1(metaSwapClone).initializeMetaSwap(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress,\n baseSwap\n );\n Ownable(metaSwapClone).transferOwnership(owner());\n emit NewSwapPool(msg.sender, metaSwapClone, _pooledTokens);\n return metaSwapClone;\n }\n}\n" + }, + "contracts/SwapUtilsV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"./AmplificationUtilsV2.sol\";\nimport \"./LPTokenV2.sol\";\nimport \"./MathUtilsV1.sol\";\n\n/**\n * @title SwapUtils library\n * @notice A library to be used within Swap.sol. Contains functions responsible for custody and AMM functionalities.\n * @dev Contracts relying on this library must initialize SwapUtils.Swap struct then use this library\n * for SwapUtils.Swap struct. Note that this library contains both functions called by users and admins.\n * Admin functions should be protected within contracts using this library.\n */\nlibrary SwapUtilsV2 {\n using SafeERC20 for IERC20;\n using MathUtilsV1 for uint256;\n\n /*** EVENTS ***/\n\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n\n struct Swap {\n // variables around the ramp management of A,\n // the amplification coefficient * n * (n - 1)\n // see https://www.curve.fi/stableswap-paper.pdf for details\n uint256 initialA;\n uint256 futureA;\n uint256 initialATime;\n uint256 futureATime;\n // fee calculation\n uint256 swapFee;\n uint256 adminFee;\n LPTokenV2 lpToken;\n // contract references for all tokens being pooled\n IERC20[] pooledTokens;\n // multipliers for each pooled token's precision to get to POOL_PRECISION_DECIMALS\n // for example, TBTC has 18 decimals, so the multiplier should be 1. WBTC\n // has 8, so the multiplier should be 10 ** 18 / 10 ** 8 => 10 ** 10\n uint256[] tokenPrecisionMultipliers;\n // the pool balance of each token, in the token's precision\n // the contract's actual token balance might differ\n uint256[] balances;\n }\n\n // Struct storing variables used in calculations in the\n // calculateWithdrawOneTokenDY function to avoid stack too deep errors\n struct CalculateWithdrawOneTokenDYInfo {\n uint256 d0;\n uint256 d1;\n uint256 newY;\n uint256 feePerToken;\n uint256 preciseA;\n }\n\n // Struct storing variables used in calculations in the\n // {add,remove}Liquidity functions to avoid stack too deep errors\n struct ManageLiquidityInfo {\n uint256 d0;\n uint256 d1;\n uint256 d2;\n uint256 preciseA;\n LPTokenV2 lpToken;\n uint256 totalSupply;\n uint256[] balances;\n uint256[] multipliers;\n }\n\n // the precision all pools tokens will be converted to\n uint8 public constant POOL_PRECISION_DECIMALS = 18;\n\n // the denominator used to calculate admin and LP fees. For example, an\n // LP fee might be something like tradeAmount * (fee) / (FEE_DENOMINATOR)\n uint256 private constant FEE_DENOMINATOR = 10**10;\n\n // Max swap fee is 1% or 100bps of each swap\n uint256 public constant MAX_SWAP_FEE = 10**8;\n\n // Max adminFee is 100% of the swapFee\n // adminFee does not add additional fee on top of swapFee\n // Instead it takes a certain % of the swapFee. Therefore it has no impact on the\n // users but only on the earnings of LPs\n uint256 public constant MAX_ADMIN_FEE = 10**10;\n\n // Constant value used as max loop limit\n uint256 private constant MAX_LOOP_LIMIT = 256;\n\n /*** VIEW & PURE FUNCTIONS ***/\n\n function _getAPrecise(Swap storage self) internal view returns (uint256) {\n return AmplificationUtilsV2._getAPrecise(self);\n }\n\n /**\n * @notice Calculate the dy, the amount of selected token that user receives and\n * the fee of withdrawing in one token\n * @param tokenAmount the amount to withdraw in the pool's precision\n * @param tokenIndex which token will be withdrawn\n * @param self Swap struct to read from\n * @return the amount of token user will receive\n */\n function calculateWithdrawOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view returns (uint256) {\n (uint256 availableTokenAmount, ) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n self.lpToken.totalSupply()\n );\n return availableTokenAmount;\n }\n\n function _calculateWithdrawOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 totalSupply\n ) internal view returns (uint256, uint256) {\n uint256 dy;\n uint256 newY;\n uint256 currentY;\n\n (dy, newY, currentY) = calculateWithdrawOneTokenDY(\n self,\n tokenIndex,\n tokenAmount,\n totalSupply\n );\n\n // dy_0 (without fees)\n // dy, dy_0 - dy\n\n uint256 dySwapFee = ((currentY - newY) /\n self.tokenPrecisionMultipliers[tokenIndex]) - dy;\n\n return (dy, dySwapFee);\n }\n\n /**\n * @notice Calculate the dy of withdrawing in one token\n * @param self Swap struct to read from\n * @param tokenIndex which token will be withdrawn\n * @param tokenAmount the amount to withdraw in the pools precision\n * @return the d and the new y after withdrawing one token\n */\n function calculateWithdrawOneTokenDY(\n Swap storage self,\n uint8 tokenIndex,\n uint256 tokenAmount,\n uint256 totalSupply\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n // Get the current D, then solve the stableswap invariant\n // y_i for D - tokenAmount\n uint256[] memory xp = _xp(self);\n\n require(tokenIndex < xp.length, \"Token index out of range\");\n\n CalculateWithdrawOneTokenDYInfo\n memory v = CalculateWithdrawOneTokenDYInfo(0, 0, 0, 0, 0);\n v.preciseA = _getAPrecise(self);\n v.d0 = getD(xp, v.preciseA);\n v.d1 = v.d0 - ((tokenAmount * v.d0) / totalSupply);\n\n require(tokenAmount <= xp[tokenIndex], \"Withdraw exceeds available\");\n\n v.newY = getYD(v.preciseA, tokenIndex, xp, v.d1);\n\n uint256[] memory xpReduced = new uint256[](xp.length);\n\n v.feePerToken = _feePerToken(self.swapFee, xp.length);\n for (uint256 i = 0; i < xp.length; i++) {\n uint256 xpi = xp[i];\n // if i == tokenIndex, dxExpected = xp[i] * d1 / d0 - newY\n // else dxExpected = xp[i] - (xp[i] * d1 / d0)\n // xpReduced[i] -= dxExpected * fee / FEE_DENOMINATOR\n xpReduced[i] =\n xpi -\n (((\n (i == tokenIndex)\n ? ((xpi * v.d1) / v.d0) - v.newY\n : xpi - ((xpi * v.d1) / v.d0)\n ) * v.feePerToken) / FEE_DENOMINATOR);\n }\n\n uint256 dy = xpReduced[tokenIndex] -\n (getYD(v.preciseA, tokenIndex, xpReduced, v.d1));\n dy = (dy - 1) / self.tokenPrecisionMultipliers[tokenIndex];\n\n return (dy, v.newY, xp[tokenIndex]);\n }\n\n /**\n * @notice Calculate the price of a token in the pool with given\n * precision-adjusted balances and a particular D.\n *\n * @dev This is accomplished via solving the invariant iteratively.\n * See the StableSwap paper and Curve.fi implementation for further details.\n *\n * x_1**2 + x1 * (sum' - (A*n**n - 1) * D / (A * n**n)) = D ** (n + 1) / (n ** (2 * n) * prod' * A)\n * x_1**2 + b*x_1 = c\n * x_1 = (x_1**2 + c) / (2*x_1 + b)\n *\n * @param a the amplification coefficient * n * (n - 1). See the StableSwap paper for details.\n * @param tokenIndex Index of token we are calculating for.\n * @param xp a precision-adjusted set of pool balances. Array should be\n * the same cardinality as the pool.\n * @param d the stableswap invariant\n * @return the price of the token, in the same precision as in xp\n */\n function getYD(\n uint256 a,\n uint8 tokenIndex,\n uint256[] memory xp,\n uint256 d\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(tokenIndex < numTokens, \"Token not found\");\n\n uint256 c = d;\n uint256 s;\n uint256 nA = a * (numTokens);\n\n for (uint256 i = 0; i < numTokens; i++) {\n if (i != tokenIndex) {\n s = s + xp[i];\n c = (c * d) / (xp[i] * (numTokens));\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n }\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\n\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\n uint256 yPrev;\n uint256 y = d;\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = ((y * y) + c) / ((y * 2) + b - d);\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Get D, the StableSwap invariant, based on a set of balances and a particular A.\n * @param xp a precision-adjusted set of pool balances. Array should be the same cardinality\n * as the pool.\n * @param a the amplification coefficient * n * (n - 1) in A_PRECISION.\n * See the StableSwap paper for details\n * @return the invariant, at the precision of the pool\n */\n function getD(uint256[] memory xp, uint256 a)\n internal\n pure\n returns (uint256)\n {\n uint256 numTokens = xp.length;\n uint256 s;\n for (uint256 i = 0; i < numTokens; i++) {\n s = s + xp[i];\n }\n if (s == 0) {\n return 0;\n }\n\n uint256 prevD;\n uint256 d = s;\n uint256 nA = a * numTokens;\n\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n uint256 dP = d;\n for (uint256 j = 0; j < numTokens; j++) {\n dP = (dP * d) / (xp[j] * numTokens);\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // dP = dP * D * D * D * ... overflow!\n }\n prevD = d;\n d =\n ((((nA * s) / AmplificationUtilsV2.A_PRECISION) +\n (dP * numTokens)) * d) /\n ((((nA - AmplificationUtilsV2.A_PRECISION) * d) /\n AmplificationUtilsV2.A_PRECISION) + ((numTokens + 1) * dP));\n if (d.within1(prevD)) {\n return d;\n }\n }\n\n // Convergence should occur in 4 loops or less. If this is reached, there may be something wrong\n // with the pool. If this were to occur repeatedly, LPs should withdraw via `removeLiquidity()`\n // function which does not rely on D.\n revert(\"D does not converge\");\n }\n\n /**\n * @notice Given a set of balances and precision multipliers, return the\n * precision-adjusted balances.\n *\n * @param balances an array of token balances, in their native precisions.\n * These should generally correspond with pooled tokens.\n *\n * @param precisionMultipliers an array of multipliers, corresponding to\n * the amounts in the balances array. When multiplied together they\n * should yield amounts at the pool's precision.\n *\n * @return an array of amounts \"scaled\" to the pool's precision\n */\n function _xp(\n uint256[] memory balances,\n uint256[] memory precisionMultipliers\n ) internal pure returns (uint256[] memory) {\n uint256 numTokens = balances.length;\n require(\n numTokens == precisionMultipliers.length,\n \"Balances must match multipliers\"\n );\n uint256[] memory xp = new uint256[](numTokens);\n for (uint256 i = 0; i < numTokens; i++) {\n xp[i] = balances[i] * precisionMultipliers[i];\n }\n return xp;\n }\n\n /**\n * @notice Return the precision-adjusted balances of all tokens in the pool\n * @param self Swap struct to read from\n * @return the pool balances \"scaled\" to the pool's precision, allowing\n * them to be more easily compared.\n */\n function _xp(Swap storage self) internal view returns (uint256[] memory) {\n return _xp(self.balances, self.tokenPrecisionMultipliers);\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @param self Swap struct to read from\n * @return the virtual price, scaled to precision of POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice(Swap storage self)\n external\n view\n returns (uint256)\n {\n uint256 d = getD(_xp(self), _getAPrecise(self));\n LPTokenV2 lpToken = self.lpToken;\n uint256 supply = lpToken.totalSupply();\n if (supply > 0) {\n return (d * (10**uint256(POOL_PRECISION_DECIMALS))) / supply;\n }\n return 0;\n }\n\n /**\n * @notice Calculate the new balances of the tokens given the indexes of the token\n * that is swapped from (FROM) and the token that is swapped to (TO).\n * This function is used as a helper function to calculate how much TO token\n * the user should receive on swap.\n *\n * @param preciseA precise form of amplification coefficient\n * @param tokenIndexFrom index of FROM token\n * @param tokenIndexTo index of TO token\n * @param x the new total amount of FROM token\n * @param xp balances of the tokens in the pool\n * @return the amount of TO token that should remain in the pool\n */\n function getY(\n uint256 preciseA,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 x,\n uint256[] memory xp\n ) internal pure returns (uint256) {\n uint256 numTokens = xp.length;\n require(\n tokenIndexFrom != tokenIndexTo,\n \"Can't compare token to itself\"\n );\n require(\n tokenIndexFrom < numTokens && tokenIndexTo < numTokens,\n \"Tokens must be in pool\"\n );\n\n uint256 d = getD(xp, preciseA);\n uint256 c = d;\n uint256 s;\n uint256 nA = numTokens * preciseA;\n\n uint256 _x;\n for (uint256 i = 0; i < numTokens; i++) {\n if (i == tokenIndexFrom) {\n _x = x;\n } else if (i != tokenIndexTo) {\n _x = xp[i];\n } else {\n continue;\n }\n s = s + _x;\n c = (c * d) / (_x * numTokens);\n // If we were to protect the division loss we would have to keep the denominator separate\n // and divide at the end. However this leads to overflow with large numTokens or/and D.\n // c = c * D * D * D * ... overflow!\n }\n c = (c * d * AmplificationUtilsV2.A_PRECISION) / (nA * numTokens);\n uint256 b = s + ((d * AmplificationUtilsV2.A_PRECISION) / nA);\n uint256 yPrev;\n uint256 y = d;\n\n // iterative approximation\n for (uint256 i = 0; i < MAX_LOOP_LIMIT; i++) {\n yPrev = y;\n y = (y * y + c) / (y * 2 + b - d);\n if (y.within1(yPrev)) {\n return y;\n }\n }\n revert(\"Approximation did not converge\");\n }\n\n /**\n * @notice Externally calculates a swap between two tokens.\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n */\n function calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view returns (uint256 dy) {\n (dy, ) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n self.balances\n );\n }\n\n /**\n * @notice Internally calculates a swap between two tokens.\n *\n * @dev The caller is expected to transfer the actual amounts (dx and dy)\n * using the token contracts.\n *\n * @param self Swap struct to read from\n * @param tokenIndexFrom the token to sell\n * @param tokenIndexTo the token to buy\n * @param dx the number of tokens to sell. If the token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @return dy the number of tokens the user will get\n * @return dyFee the associated fee\n */\n function _calculateSwap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256[] memory balances\n ) internal view returns (uint256 dy, uint256 dyFee) {\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n uint256[] memory xp = _xp(balances, multipliers);\n require(\n tokenIndexFrom < xp.length && tokenIndexTo < xp.length,\n \"Token index out of range\"\n );\n uint256 x = dx * multipliers[tokenIndexFrom] + xp[tokenIndexFrom];\n uint256 y = getY(\n _getAPrecise(self),\n tokenIndexFrom,\n tokenIndexTo,\n x,\n xp\n );\n dy = xp[tokenIndexTo] - y - 1;\n dyFee = (dy * self.swapFee) / FEE_DENOMINATOR;\n dy = (dy - dyFee) / multipliers[tokenIndexTo];\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of\n * LP tokens\n *\n * @param amount the amount of LP tokens that would to be burned on\n * withdrawal\n * @return array of amounts of tokens user will receive\n */\n function calculateRemoveLiquidity(Swap storage self, uint256 amount)\n external\n view\n returns (uint256[] memory)\n {\n return\n _calculateRemoveLiquidity(\n self.balances,\n amount,\n self.lpToken.totalSupply()\n );\n }\n\n function _calculateRemoveLiquidity(\n uint256[] memory balances,\n uint256 amount,\n uint256 totalSupply\n ) internal pure returns (uint256[] memory) {\n require(amount <= totalSupply, \"Cannot exceed total supply\");\n\n uint256[] memory amounts = new uint256[](balances.length);\n\n for (uint256 i = 0; i < balances.length; i++) {\n amounts[i] = (balances[i] * amount) / totalSupply;\n }\n return amounts;\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param self Swap struct to read from\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return if deposit was true, total amount of lp token that will be minted and if\n * deposit was false, total amount of lp token that will be burned\n */\n function calculateTokenAmount(\n Swap storage self,\n uint256[] calldata amounts,\n bool deposit\n ) external view returns (uint256) {\n uint256 a = _getAPrecise(self);\n uint256[] memory balances = self.balances;\n uint256[] memory multipliers = self.tokenPrecisionMultipliers;\n\n uint256 d0 = getD(_xp(balances, multipliers), a);\n for (uint256 i = 0; i < balances.length; i++) {\n if (deposit) {\n balances[i] = balances[i] + amounts[i];\n } else {\n if (amounts[i] > balances[i]) {\n revert(\"Cannot withdraw more than available\");\n } else {\n unchecked {\n balances[i] = balances[i] - amounts[i];\n }\n }\n }\n }\n uint256 d1 = getD(_xp(balances, multipliers), a);\n uint256 totalSupply = self.lpToken.totalSupply();\n\n if (deposit) {\n return (((d1 - d0) * totalSupply) / d0);\n } else {\n return (((d0 - d1) * totalSupply) / d0);\n }\n }\n\n /**\n * @notice return accumulated amount of admin fees of the token with given index\n * @param self Swap struct to read from\n * @param index Index of the pooled token\n * @return admin balance in the token's precision\n */\n function getAdminBalance(Swap storage self, uint256 index)\n external\n view\n returns (uint256)\n {\n require(index < self.pooledTokens.length, \"Token index out of range\");\n return\n self.pooledTokens[index].balanceOf(address(this)) -\n self.balances[index];\n }\n\n /**\n * @notice internal helper function to calculate fee per token multiplier used in\n * swap fee calculations\n * @param swapFee swap fee for the tokens\n * @param numTokens number of tokens pooled\n */\n function _feePerToken(uint256 swapFee, uint256 numTokens)\n internal\n pure\n returns (uint256)\n {\n return ((swapFee * numTokens) / ((numTokens - 1) * 4));\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice swap two tokens in the pool\n * @param self Swap struct to read from and write to\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell\n * @param minDy the min amount the user would like to receive, or revert.\n * @return amount of token user received on swap\n */\n function swap(\n Swap storage self,\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy\n ) external returns (uint256) {\n {\n IERC20 tokenFrom = self.pooledTokens[tokenIndexFrom];\n require(\n dx <= tokenFrom.balanceOf(msg.sender),\n \"Cannot swap more than you own\"\n );\n // Transfer tokens first to see if a fee was charged on transfer\n uint256 beforeBalance = tokenFrom.balanceOf(address(this));\n tokenFrom.safeTransferFrom(msg.sender, address(this), dx);\n\n // Use the actual transferred amount for AMM math\n dx = tokenFrom.balanceOf(address(this)) - beforeBalance;\n }\n\n uint256 dy;\n uint256 dyFee;\n uint256[] memory balances = self.balances;\n (dy, dyFee) = _calculateSwap(\n self,\n tokenIndexFrom,\n tokenIndexTo,\n dx,\n balances\n );\n require(dy >= minDy, \"Swap didn't result in min tokens\");\n\n uint256 dyAdminFee = (((dyFee * self.adminFee) / FEE_DENOMINATOR) /\n self.tokenPrecisionMultipliers[tokenIndexTo]);\n\n self.balances[tokenIndexFrom] = balances[tokenIndexFrom] + dx;\n self.balances[tokenIndexTo] = balances[tokenIndexTo] - dy - dyAdminFee;\n\n self.pooledTokens[tokenIndexTo].safeTransfer(msg.sender, dy);\n\n emit TokenSwap(msg.sender, dx, dy, tokenIndexFrom, tokenIndexTo);\n\n return dy;\n }\n\n /**\n * @notice Add liquidity to the pool\n * @param self Swap struct to read from and write to\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * allowed addresses. If the pool is not in the guarded launch phase, this parameter will be ignored.\n * @return amount of LP token user received\n */\n function addLiquidity(\n Swap storage self,\n uint256[] memory amounts,\n uint256 minToMint\n ) external returns (uint256) {\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(\n amounts.length == pooledTokens.length,\n \"Amounts must match pooled tokens\"\n );\n\n // current state\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n if (v.totalSupply != 0) {\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n }\n\n uint256[] memory newBalances = new uint256[](pooledTokens.length);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n require(\n v.totalSupply != 0 || amounts[i] > 0,\n \"Must supply all tokens in pool\"\n );\n\n // Transfer tokens first to see if a fee was charged on transfer\n if (amounts[i] != 0) {\n uint256 beforeBalance = pooledTokens[i].balanceOf(\n address(this)\n );\n pooledTokens[i].safeTransferFrom(\n msg.sender,\n address(this),\n amounts[i]\n );\n\n // Update the amounts[] with actual transfer amount\n amounts[i] =\n pooledTokens[i].balanceOf(address(this)) -\n beforeBalance;\n }\n\n newBalances[i] = v.balances[i] + amounts[i];\n }\n // invariant after change\n v.d1 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n require(v.d1 > v.d0, \"D should increase\");\n // updated to reflect fees and calculate the user's LP tokens\n v.d2 = v.d1;\n uint256[] memory fees = new uint256[](pooledTokens.length);\n\n if (v.totalSupply != 0) {\n uint256 feePerToken = _feePerToken(\n self.swapFee,\n pooledTokens.length\n );\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\n fees[i] =\n (feePerToken * idealBalance.difference(newBalances[i])) /\n FEE_DENOMINATOR;\n self.balances[i] =\n newBalances[i] -\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\n newBalances[i] = newBalances[i] - fees[i];\n }\n v.d2 = getD(_xp(newBalances, v.multipliers), v.preciseA);\n } else {\n // the initial depositor doesn't pay fees\n self.balances = newBalances;\n }\n\n uint256 toMint;\n if (v.totalSupply == 0) {\n toMint = v.d1;\n } else {\n toMint = ((v.d2 - v.d0) * v.totalSupply) / v.d0;\n }\n\n require(toMint >= minToMint, \"Couldn't mint min requested\");\n\n // mint the user's LP tokens\n v.lpToken.mint(msg.sender, toMint);\n\n emit AddLiquidity(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply + toMint\n );\n\n return toMint;\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param self Swap struct to read from and write to\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @return amounts of tokens the user received\n */\n function removeLiquidity(\n Swap storage self,\n uint256 amount,\n uint256[] calldata minAmounts\n ) external returns (uint256[] memory) {\n LPTokenV2 lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n require(amount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(\n minAmounts.length == pooledTokens.length,\n \"minAmounts must match poolTokens\"\n );\n\n uint256[] memory balances = self.balances;\n uint256 totalSupply = lpToken.totalSupply();\n\n uint256[] memory amounts = _calculateRemoveLiquidity(\n balances,\n amount,\n totalSupply\n );\n\n for (uint256 i = 0; i < amounts.length; i++) {\n require(amounts[i] >= minAmounts[i], \"amounts[i] < minAmounts[i]\");\n self.balances[i] = balances[i] - amounts[i];\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n lpToken.burnFrom(msg.sender, amount);\n\n emit RemoveLiquidity(msg.sender, amounts, totalSupply - amount);\n\n return amounts;\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token.\n * @param self Swap struct to read from and write to\n * @param tokenAmount the amount of the lp tokens to burn\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @return amount chosen token that user received\n */\n function removeLiquidityOneToken(\n Swap storage self,\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount\n ) external returns (uint256) {\n LPTokenV2 lpToken = self.lpToken;\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(tokenAmount <= lpToken.balanceOf(msg.sender), \">LP.balanceOf\");\n require(tokenIndex < pooledTokens.length, \"Token not found\");\n\n uint256 totalSupply = lpToken.totalSupply();\n\n (uint256 dy, uint256 dyFee) = _calculateWithdrawOneToken(\n self,\n tokenAmount,\n tokenIndex,\n totalSupply\n );\n\n require(dy >= minAmount, \"dy < minAmount\");\n\n self.balances[tokenIndex] =\n self.balances[tokenIndex] -\n (dy + ((dyFee * self.adminFee) / FEE_DENOMINATOR));\n lpToken.burnFrom(msg.sender, tokenAmount);\n pooledTokens[tokenIndex].safeTransfer(msg.sender, dy);\n\n emit RemoveLiquidityOne(\n msg.sender,\n tokenAmount,\n totalSupply,\n tokenIndex,\n dy\n );\n\n return dy;\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances.\n *\n * @param self Swap struct to read from and write to\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @return actual amount of LP tokens burned in the withdrawal\n */\n function removeLiquidityImbalance(\n Swap storage self,\n uint256[] memory amounts,\n uint256 maxBurnAmount\n ) public returns (uint256) {\n ManageLiquidityInfo memory v = ManageLiquidityInfo(\n 0,\n 0,\n 0,\n _getAPrecise(self),\n self.lpToken,\n 0,\n self.balances,\n self.tokenPrecisionMultipliers\n );\n v.totalSupply = v.lpToken.totalSupply();\n\n IERC20[] memory pooledTokens = self.pooledTokens;\n\n require(\n amounts.length == pooledTokens.length,\n \"Amounts should match pool tokens\"\n );\n\n require(\n maxBurnAmount <= v.lpToken.balanceOf(msg.sender) &&\n maxBurnAmount != 0,\n \">LP.balanceOf\"\n );\n\n uint256 feePerToken = _feePerToken(self.swapFee, pooledTokens.length);\n uint256[] memory fees = new uint256[](pooledTokens.length);\n {\n uint256[] memory balances1 = new uint256[](pooledTokens.length);\n v.d0 = getD(_xp(v.balances, v.multipliers), v.preciseA);\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n if (amounts[i] > v.balances[i]) {\n revert(\"Cannot withdraw more than available\");\n } else {\n unchecked {\n balances1[i] = v.balances[i] - amounts[i];\n }\n }\n }\n v.d1 = getD(_xp(balances1, v.multipliers), v.preciseA);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n uint256 idealBalance = (v.d1 * v.balances[i]) / v.d0;\n uint256 difference = idealBalance.difference(balances1[i]);\n fees[i] = (feePerToken * difference) / FEE_DENOMINATOR;\n self.balances[i] =\n balances1[i] -\n ((fees[i] * self.adminFee) / FEE_DENOMINATOR);\n balances1[i] = balances1[i] - fees[i];\n }\n\n v.d2 = getD(_xp(balances1, v.multipliers), v.preciseA);\n }\n uint256 tokenAmount = ((v.d0 - v.d2) * v.totalSupply) / v.d0;\n require(tokenAmount != 0, \"Burnt amount cannot be zero\");\n tokenAmount = tokenAmount + 1;\n\n require(tokenAmount <= maxBurnAmount, \"tokenAmount > maxBurnAmount\");\n\n v.lpToken.burnFrom(msg.sender, tokenAmount);\n\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n pooledTokens[i].safeTransfer(msg.sender, amounts[i]);\n }\n\n emit RemoveLiquidityImbalance(\n msg.sender,\n amounts,\n fees,\n v.d1,\n v.totalSupply - tokenAmount\n );\n\n return tokenAmount;\n }\n\n /**\n * @notice withdraw all admin fees to a given address\n * @param self Swap struct to withdraw fees from\n * @param to Address to send the fees to\n */\n function withdrawAdminFees(Swap storage self, address to) external {\n IERC20[] memory pooledTokens = self.pooledTokens;\n for (uint256 i = 0; i < pooledTokens.length; i++) {\n IERC20 token = pooledTokens[i];\n uint256 balance = token.balanceOf(address(this)) - self.balances[i];\n if (balance != 0) {\n token.safeTransfer(to, balance);\n }\n }\n }\n\n /**\n * @notice Sets the admin fee\n * @dev adminFee cannot be higher than 100% of the swap fee\n * @param self Swap struct to update\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(Swap storage self, uint256 newAdminFee) external {\n require(newAdminFee <= MAX_ADMIN_FEE, \"Fee is too high\");\n self.adminFee = newAdminFee;\n\n emit NewAdminFee(newAdminFee);\n }\n\n /**\n * @notice update the swap fee\n * @dev fee cannot be higher than 1% of each swap\n * @param self Swap struct to update\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(Swap storage self, uint256 newSwapFee) external {\n require(newSwapFee <= MAX_SWAP_FEE, \"Fee is too high\");\n self.swapFee = newSwapFee;\n\n emit NewSwapFee(newSwapFee);\n }\n}\n" + }, + "contracts/SwapV2.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts-4.7.3/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-4.7.3/proxy/Clones.sol\";\nimport \"@openzeppelin/contracts-upgradeable-4.7.3/security/ReentrancyGuardUpgradeable.sol\";\nimport \"./OwnerPausableUpgradeableV1.sol\";\nimport \"./SwapUtilsV2.sol\";\nimport \"./AmplificationUtilsV2.sol\";\n\n/**\n * @title Swap - A StableSwap implementation in solidity.\n * @notice This contract is responsible for custody of closely pegged assets (eg. group of stablecoins)\n * and automatic market making system. Users become an LP (Liquidity Provider) by depositing their tokens\n * in desired ratios for an exchange of the pool token that represents their share of the pool.\n * Users can burn pool tokens and withdraw their share of token(s).\n *\n * Each time a swap between the pooled tokens happens, a set fee incurs which effectively gets\n * distributed to the LPs.\n *\n * In case of emergencies, admin can pause additional deposits, swaps, or single-asset withdraws - which\n * stops the ratio of the tokens in the pool from changing.\n * Users can always withdraw their tokens via multi-asset withdraws.\n *\n * @dev Most of the logic is stored as a library `SwapUtils` for the sake of reducing contract's\n * deployment size.\n */\ncontract SwapV2 is OwnerPausableUpgradeableV1, ReentrancyGuardUpgradeable {\n using SafeERC20 for IERC20;\n using SwapUtilsV2 for SwapUtilsV2.Swap;\n using AmplificationUtilsV2 for SwapUtilsV2.Swap;\n\n // Struct storing data responsible for automatic market maker functionalities. In order to\n // access this data, this contract uses SwapUtils library. For more details, see SwapUtils.sol\n SwapUtilsV2.Swap public swapStorage;\n\n // Maps token address to an index in the pool. Used to prevent duplicate tokens in the pool.\n // getTokenIndex function also relies on this mapping to retrieve token index.\n mapping(address => uint8) private tokenIndexes;\n\n /*** EVENTS ***/\n\n // events replicated from SwapUtils to make the ABI easier for dumb\n // clients\n event TokenSwap(\n address indexed buyer,\n uint256 tokensSold,\n uint256 tokensBought,\n uint128 soldId,\n uint128 boughtId\n );\n event AddLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event RemoveLiquidity(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256 lpTokenSupply\n );\n event RemoveLiquidityOne(\n address indexed provider,\n uint256 lpTokenAmount,\n uint256 lpTokenSupply,\n uint256 boughtId,\n uint256 tokensBought\n );\n event RemoveLiquidityImbalance(\n address indexed provider,\n uint256[] tokenAmounts,\n uint256[] fees,\n uint256 invariant,\n uint256 lpTokenSupply\n );\n event NewAdminFee(uint256 newAdminFee);\n event NewSwapFee(uint256 newSwapFee);\n event NewWithdrawFee(uint256 newWithdrawFee);\n event RampA(\n uint256 oldA,\n uint256 newA,\n uint256 initialTime,\n uint256 futureTime\n );\n event StopRampA(uint256 currentA, uint256 time);\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function initialize(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) public payable virtual initializer {\n __SwapV2_init(\n _pooledTokens,\n decimals,\n lpTokenName,\n lpTokenSymbol,\n _a,\n _fee,\n _adminFee,\n lpTokenTargetAddress\n );\n }\n\n /**\n * @notice Initializes this Swap contract with the given parameters.\n * This will also clone a LPToken contract that represents users'\n * LP positions. The owner of LPToken will be this contract - which means\n * only this contract is allowed to mint/burn tokens.\n *\n * @param _pooledTokens an array of ERC20s this pool will accept\n * @param decimals the decimals to use for each pooled token,\n * eg 8 for WBTC. Cannot be larger than POOL_PRECISION_DECIMALS\n * @param lpTokenName the long-form name of the token to be deployed\n * @param lpTokenSymbol the short symbol for the token to be deployed\n * @param _a the amplification coefficient * n * (n - 1). See the\n * StableSwap paper for details\n * @param _fee default swap fee to be initialized with\n * @param _adminFee default adminFee to be initialized with\n * @param lpTokenTargetAddress the address of an existing LPToken contract to use as a target\n */\n function __SwapV2_init(\n IERC20[] memory _pooledTokens,\n uint8[] memory decimals,\n string memory lpTokenName,\n string memory lpTokenSymbol,\n uint256 _a,\n uint256 _fee,\n uint256 _adminFee,\n address lpTokenTargetAddress\n ) internal virtual onlyInitializing {\n __OwnerPausable_init();\n __ReentrancyGuard_init();\n // Check _pooledTokens and precisions parameter\n require(_pooledTokens.length > 1, \"_pooledTokens.length <= 1\");\n require(_pooledTokens.length <= 32, \"_pooledTokens.length > 32\");\n require(\n _pooledTokens.length == decimals.length,\n \"_pooledTokens decimals mismatch\"\n );\n\n uint256[] memory precisionMultipliers = new uint256[](decimals.length);\n\n for (uint8 i = 0; i < _pooledTokens.length; i++) {\n if (i > 0) {\n // Check if index is already used. Check if 0th element is a duplicate.\n require(\n tokenIndexes[address(_pooledTokens[i])] == 0 &&\n _pooledTokens[0] != _pooledTokens[i],\n \"Duplicate tokens\"\n );\n }\n require(\n address(_pooledTokens[i]) != address(0),\n \"The 0 address isn't an ERC-20\"\n );\n require(\n decimals[i] <= SwapUtilsV2.POOL_PRECISION_DECIMALS,\n \"Token decimals exceeds max\"\n );\n precisionMultipliers[i] =\n 10 **\n (uint256(SwapUtilsV2.POOL_PRECISION_DECIMALS) -\n uint256(decimals[i]));\n tokenIndexes[address(_pooledTokens[i])] = i;\n }\n\n // Check _a, _fee, _adminFee, _withdrawFee parameters\n require(_a < AmplificationUtilsV2.MAX_A, \"_a exceeds maximum\");\n require(_fee < SwapUtilsV2.MAX_SWAP_FEE, \"_fee exceeds maximum\");\n require(\n _adminFee < SwapUtilsV2.MAX_ADMIN_FEE,\n \"_adminFee exceeds maximum\"\n );\n\n // Clone and initialize a LPToken contract\n LPTokenV2 lpToken = LPTokenV2(Clones.clone(lpTokenTargetAddress));\n require(\n lpToken.initialize(lpTokenName, lpTokenSymbol),\n \"could not init lpToken clone\"\n );\n\n // Initialize swapStorage struct\n swapStorage.lpToken = lpToken;\n swapStorage.pooledTokens = _pooledTokens;\n swapStorage.tokenPrecisionMultipliers = precisionMultipliers;\n swapStorage.balances = new uint256[](_pooledTokens.length);\n swapStorage.initialA = _a * AmplificationUtilsV2.A_PRECISION;\n swapStorage.futureA = _a * AmplificationUtilsV2.A_PRECISION;\n // swapStorage.initialATime = 0;\n // swapStorage.futureATime = 0;\n swapStorage.swapFee = _fee;\n swapStorage.adminFee = _adminFee;\n }\n\n /*** MODIFIERS ***/\n\n /**\n * @notice Modifier to check deadline against current timestamp\n * @param deadline latest timestamp to accept this transaction\n */\n modifier deadlineCheck(uint256 deadline) {\n require(block.timestamp <= deadline, \"Deadline not met\");\n _;\n }\n\n /*** VIEW FUNCTIONS ***/\n\n /**\n * @notice Return A, the amplification coefficient * n * (n - 1)\n * @dev See the StableSwap paper for details\n * @return A parameter\n */\n function getA() external view virtual returns (uint256) {\n return swapStorage.getA();\n }\n\n /**\n * @notice Return A in its raw precision form\n * @dev See the StableSwap paper for details\n * @return A parameter in its raw precision form\n */\n function getAPrecise() external view virtual returns (uint256) {\n return swapStorage.getAPrecise();\n }\n\n /**\n * @notice Return address of the pooled token at given index. Reverts if tokenIndex is out of range.\n * @param index the index of the token\n * @return address of the token at given index\n */\n function getToken(uint8 index) public view virtual returns (IERC20) {\n require(index < swapStorage.pooledTokens.length, \"Out of range\");\n return swapStorage.pooledTokens[index];\n }\n\n /**\n * @notice Return the index of the given token address. Reverts if no matching\n * token is found.\n * @param tokenAddress address of the token\n * @return the index of the given token address\n */\n function getTokenIndex(address tokenAddress)\n public\n view\n virtual\n returns (uint8)\n {\n uint8 index = tokenIndexes[tokenAddress];\n require(\n address(getToken(index)) == tokenAddress,\n \"Token does not exist\"\n );\n return index;\n }\n\n /**\n * @notice Return current balance of the pooled token at given index\n * @param index the index of the token\n * @return current balance of the pooled token at given index with token's native precision\n */\n function getTokenBalance(uint8 index)\n external\n view\n virtual\n returns (uint256)\n {\n require(index < swapStorage.pooledTokens.length, \"Index out of range\");\n return swapStorage.balances[index];\n }\n\n /**\n * @notice Get the virtual price, to help calculate profit\n * @return the virtual price, scaled to the POOL_PRECISION_DECIMALS\n */\n function getVirtualPrice() external view virtual returns (uint256) {\n return swapStorage.getVirtualPrice();\n }\n\n /**\n * @notice Calculate amount of tokens you receive on swap\n * @param tokenIndexFrom the token the user wants to sell\n * @param tokenIndexTo the token the user wants to buy\n * @param dx the amount of tokens the user wants to sell. If the token charges\n * a fee on transfers, use the amount that gets transferred after the fee.\n * @return amount of tokens the user will receive\n */\n function calculateSwap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx\n ) external view virtual returns (uint256) {\n return swapStorage.calculateSwap(tokenIndexFrom, tokenIndexTo, dx);\n }\n\n /**\n * @notice A simple method to calculate prices from deposits or\n * withdrawals, excluding fees but including slippage. This is\n * helpful as an input into the various \"min\" parameters on calls\n * to fight front-running\n *\n * @dev This shouldn't be used outside frontends for user estimates.\n *\n * @param amounts an array of token amounts to deposit or withdrawal,\n * corresponding to pooledTokens. The amount should be in each\n * pooled token's native precision. If a token charges a fee on transfers,\n * use the amount that gets transferred after the fee.\n * @param deposit whether this is a deposit or a withdrawal\n * @return token amount the user will receive\n */\n function calculateTokenAmount(uint256[] calldata amounts, bool deposit)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.calculateTokenAmount(amounts, deposit);\n }\n\n /**\n * @notice A simple method to calculate amount of each underlying\n * tokens that is returned upon burning given amount of LP tokens\n * @param amount the amount of LP tokens that would be burned on withdrawal\n * @return array of token balances that the user will receive\n */\n function calculateRemoveLiquidity(uint256 amount)\n external\n view\n virtual\n returns (uint256[] memory)\n {\n return swapStorage.calculateRemoveLiquidity(amount);\n }\n\n /**\n * @notice Calculate the amount of underlying token available to withdraw\n * when withdrawing via only single token\n * @param tokenAmount the amount of LP token to burn\n * @param tokenIndex index of which token will be withdrawn\n * @return availableTokenAmount calculated amount of underlying token\n * available to withdraw\n */\n function calculateRemoveLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex\n ) external view virtual returns (uint256 availableTokenAmount) {\n return swapStorage.calculateWithdrawOneToken(tokenAmount, tokenIndex);\n }\n\n /**\n * @notice This function reads the accumulated amount of admin fees of the token with given index\n * @param index Index of the pooled token\n * @return admin's token balance in the token's precision\n */\n function getAdminBalance(uint256 index)\n external\n view\n virtual\n returns (uint256)\n {\n return swapStorage.getAdminBalance(index);\n }\n\n /*** STATE MODIFYING FUNCTIONS ***/\n\n /**\n * @notice Swap two tokens using this pool\n * @param tokenIndexFrom the token the user wants to swap from\n * @param tokenIndexTo the token the user wants to swap to\n * @param dx the amount of tokens the user wants to swap from\n * @param minDy the min amount the user would like to receive, or revert.\n * @param deadline latest timestamp to accept this transaction\n */\n function swap(\n uint8 tokenIndexFrom,\n uint8 tokenIndexTo,\n uint256 dx,\n uint256 minDy,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.swap(tokenIndexFrom, tokenIndexTo, dx, minDy);\n }\n\n /**\n * @notice Add liquidity to the pool with the given amounts of tokens\n * @param amounts the amounts of each token to add, in their native precision\n * @param minToMint the minimum LP tokens adding this amount of liquidity\n * should mint, otherwise revert. Handy for front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP token user minted and received\n */\n function addLiquidity(\n uint256[] calldata amounts,\n uint256 minToMint,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.addLiquidity(amounts, minToMint);\n }\n\n /**\n * @notice Burn LP tokens to remove liquidity from the pool. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @dev Liquidity can always be removed, even when the pool is paused.\n * @param amount the amount of LP tokens to burn\n * @param minAmounts the minimum amounts of each token in the pool\n * acceptable for this burn. Useful as a front-running mitigation\n * @param deadline latest timestamp to accept this transaction\n * @return amounts of tokens user received\n */\n function removeLiquidity(\n uint256 amount,\n uint256[] calldata minAmounts,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n deadlineCheck(deadline)\n returns (uint256[] memory)\n {\n return swapStorage.removeLiquidity(amount, minAmounts);\n }\n\n /**\n * @notice Remove liquidity from the pool all in one token. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param tokenAmount the amount of the token you want to receive\n * @param tokenIndex the index of the token you want to receive\n * @param minAmount the minimum amount to withdraw, otherwise revert\n * @param deadline latest timestamp to accept this transaction\n * @return amount of chosen token user received\n */\n function removeLiquidityOneToken(\n uint256 tokenAmount,\n uint8 tokenIndex,\n uint256 minAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return\n swapStorage.removeLiquidityOneToken(\n tokenAmount,\n tokenIndex,\n minAmount\n );\n }\n\n /**\n * @notice Remove liquidity from the pool, weighted differently than the\n * pool's current balances. Withdraw fee that decays linearly\n * over period of 4 weeks since last deposit will apply.\n * @param amounts how much of each token to withdraw\n * @param maxBurnAmount the max LP token provider is willing to pay to\n * remove liquidity. Useful as a front-running mitigation.\n * @param deadline latest timestamp to accept this transaction\n * @return amount of LP tokens burned\n */\n function removeLiquidityImbalance(\n uint256[] calldata amounts,\n uint256 maxBurnAmount,\n uint256 deadline\n )\n external\n payable\n virtual\n nonReentrant\n whenNotPaused\n deadlineCheck(deadline)\n returns (uint256)\n {\n return swapStorage.removeLiquidityImbalance(amounts, maxBurnAmount);\n }\n\n /*** ADMIN FUNCTIONS ***/\n\n /**\n * @notice Withdraw all admin fees to the contract owner\n */\n function withdrawAdminFees() external payable virtual onlyOwner {\n swapStorage.withdrawAdminFees(owner());\n }\n\n /**\n * @notice Update the admin fee. Admin fee takes portion of the swap fee.\n * @param newAdminFee new admin fee to be applied on future transactions\n */\n function setAdminFee(uint256 newAdminFee) external payable onlyOwner {\n swapStorage.setAdminFee(newAdminFee);\n }\n\n /**\n * @notice Update the swap fee to be applied on swaps\n * @param newSwapFee new swap fee to be applied on future transactions\n */\n function setSwapFee(uint256 newSwapFee) external payable onlyOwner {\n swapStorage.setSwapFee(newSwapFee);\n }\n\n /**\n * @notice Start ramping up or down A parameter towards given futureA and futureTime\n * Checks if the change is too rapid, and commits the new A value only when it falls under\n * the limit range.\n * @param futureA the new A to ramp towards\n * @param futureTime timestamp when the new A should be reached\n */\n function rampA(uint256 futureA, uint256 futureTime)\n external\n payable\n onlyOwner\n {\n swapStorage.rampA(futureA, futureTime);\n }\n\n /**\n * @notice Stop ramping A immediately. Reverts if ramp A is already stopped.\n */\n function stopRampA() external payable onlyOwner {\n swapStorage.stopRampA();\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 10000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index f9e33ba8..48b1fdb9 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -177,6 +177,17 @@ const config: HardhatUserConfig = { }, }, }, + base_testnet: { + url: "https://goerli.base.org", + chainId: parseInt(CHAIN_ID.BASE_TESTNET), + deploy: ["./deploy/base_testnet/"], + verify: { + etherscan: { + apiUrl: "https://api-goerli.basescan.org", + apiKey: process.env.ETHERSCAN_API ?? "NO_KEY", + }, + }, + }, }, paths: { sources: "./contracts", @@ -269,6 +280,7 @@ const config: HardhatUserConfig = { 2222: 0, // use the same address on kava testnet 3: 0, // use the same address on ropsten 1313161554: 0, // use the same address on aurora mainnet + 84531: 0, // use the same address on base testnet }, multisig: { default: 0, @@ -284,6 +296,22 @@ const config: HardhatUserConfig = { overwrite: false, runOnCompile: true, }, + + etherscan: { + apiKey: { + base_testnet: process.env.ETHERSCAN_API ?? "NO_KEY", + }, + customChains: [ + { + network: "base_testnet", + chainId: 84531, + urls: { + apiURL: "https://api-goerli.basescan.org/api", + browserURL: "https://goerli.basescan.org/", + }, + }, + ], + }, } // If we have any private keys, use them for mainnet networks as default signers diff --git a/utils/network.ts b/utils/network.ts index b1268354..5eee152d 100644 --- a/utils/network.ts +++ b/utils/network.ts @@ -19,6 +19,7 @@ export const CHAIN_ID: Record = { KAVA_TESTNET: "2221", KAVA_MAINNET: "2222", AURORA_MAINNET: "1313161554", + BASE_TESTNET: "84531", } // Reverse lookup of chainId to chain name @@ -52,7 +53,8 @@ export function isTestNetwork(networkId: string): boolean { networkId === CHAIN_ID.OPTIMISM_TESTNET || networkId === CHAIN_ID.FANTOM_TESTNET || networkId === CHAIN_ID.EVMOS_TESTNET || - networkId === CHAIN_ID.KAVA_TESTNET + networkId === CHAIN_ID.KAVA_TESTNET || + networkId == CHAIN_ID.BASE_TESTNET ) }